-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation or example of calling a Contract method? #107
Comments
This process is kinda unclear for now. The result is List<Any?> since "outputs" of a smart contract method may contain multiple types. The example of such an input is below: They automatically decoded using ABI, but we can't know the returning types in compile time, so we have to cast it manually. class NftContract(
private val wrapped: SmartContract
) {
suspend fun name() = wrapped.read(
method = "name",
params = emptyList()
) { (name) → name as String }
} |
You should know underlying types for encoders/decoders to do mappings. That's kinda internal thing for now and it's not documented properly. Example of mappings: bytes* → ByteArray |
This comment was marked as resolved.
This comment was marked as resolved.
Got it working, thanks! I also realized I should have been using localhost instead of infura as my endpoint. something like this is what I had to use:
|
what would be the correct way to write a mapper for this case:
I get this error:
I've tried things like:
|
Basically I'm returning an array of a struct. Is that able to be parsed at the moment? Or was that not implemented here? Seem's like that's a newer feature introduced in solidity 0.8.0 |
That should work, but how the library would know what is |
But maybe it doesn't implemented, hard to say |
The implementation of array[] type should work for any type |
If I leave it as a mapper with List<Any?> And comment out the require that is failing:
|
Give please the calldata you are trying to encode, I will investigate it soon |
this is the contract.
This is a response after minting one token that needs to be decoded.
That's what you need right? |
Yep thank you |
Working on this now in symbiosis-finance/moko-web3 |
I'm trying to simply get the name of a ERC721 contract.
First of all I'm not really sure what a valid mapper would look like? Or why it would return multiple values from one read. Do you have any examples? And second,
names
ends up being empty, so nothing is being returned? Any help on the correct way to call a contract method would be appreciated.The text was updated successfully, but these errors were encountered: