Keep getting this error and really not sure what's causing it.
Smart contract:
contract BasaltStore {
// struct of how a document will be stored
struct documentStore {
// unique id of the doc
uint256 id;
// the url of the ipfs node where the document is stored
string ipfsHash;
// wallet address of who uploaded the document
address uploader;
// date the document was uploaded (created here)
uint dateUploaded;
}
// mapping of all documents
mapping (uint64 => documentStore) public ListOfDocuments;
// count of all documents stored
uint256 public documentCount;
/** Stores the newly created document details */
function sendDocument(
string memory _ipfsLocation,
uint256 _uploadDate,
uint64 _key
)
public
{
documentCount ++;
ListOfDocuments[_key] = documentStore(documentCount, _ipfsLocation, msg.sender, _uploadDate);
}
/** Retrieves docuement details */
function getDocument(
uint64 _id
)
public
view
returns (string memory, address, uint256)
{
// return the attributes of the documentStore we need
string memory ipfsHash = ListOfDocuments[_id].ipfsHash;
address uploader = ListOfDocuments[_id].uploader;
uint256 dateUploaded = ListOfDocuments[_id].dateUploaded;
return (ipfsHash, uploader, dateUploaded);
}
}
React code calling smart contract:
var key = this.state.StudentNumber + this.state.account[0]
key = parseInt(hash(key), 10)
this.setState({idForBlockchain: key})
console.log(key)
//get todays date
let newDate = new Date()
newDate = newDate.getTime()
var _ipfsLink = this.state.IPFSlink
var _account = this.state.account[0]
await storehash.methods.sendDocument(_ipfsLink, newDate, key).send({from: _account})
//call the smart contract method to create a new document
//storehash.methods.sendDocument(this.state.IPFSlink, newDate).send({from: this.state.account})
console.log("adding student")
await this.createStudent(e)
console.log("student added")
It seems to fail after calling the
await storehash.methods.sendDocument(_ipfsLink, newDate, key).send({from: _account})
Can anyone help me figure out what's going wrong?