Closed Scott1803 closed 2 years ago
The reason is that addPost
is mutable: It changes the contract's state which requires a transaction on the blockchain.
Calling addPost
will return the transaction's hash, which can be used to obtain more information after the transaction has been included in a block. AFAIK, there's no good way to return values from a mutable function (see e.g. this) outside of using events.
I have created a simple extension of an ERC-721Enumerable token using OpenZeppelin.
The contract includes a function called "addPost", that is supposed to mint the token and return the generated tokenId. The contract code, generated dart code and dart code calling the contract function is added below.
I used the code generation feature to convert the contract to a dart file, which worked fine. However, when I call the function, I could not figure out how to get the expected uint256 return value in dart. Instead, I get a string value starting in "AxB..." that presumably represents an ethereum address.
I'm fairly new to solidity and web3, so I may very well be missing something really obvious.. Any help would be greatly appreciated!
Solidity Contract Code:
Generated Dart Code:
Dart Code calling the "addPost" method in the contract: