Hello. I am having issues with the eth_contract
macro.
Consider a situation in which I have an Ethereum contract called TwoGather.sol
, and discovery compile
successfully compiles it into the build folder as build/smart_contracts/TwoGather.json
First question: It seems that I cannot just pass this file to the eth_contract
macro, but that I first need to extract only the array that can be found at the abi
property, is that correct? I was getting errors passing the file from the build/smart_contracts
folder and that seemed to get me further.
I think a good developer flow would allow the entire built build/smart_contracts/TwoGather.json
file to be passed. Thank you for clarifying this issue/question.
Second, after creating a second json file that contains only the array that could be found at the abi
property from the TwoGather.json
file called TwoGather_abi_only.json
, I am now getting this parsing error, with no further clarification on the issue.
97 | #[eth_contract("TwoGather_abi_only.json")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: called `Result::unwrap()` on an `Err` value: TokenParseError { error: "unexpected token" }
And here is the contents of TwoGather_abi_only.json
:
[
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"constant": false,
"inputs": [
{
"name": "proposal_id",
"type": "bytes[48]"
}
],
"name": "activateProposal",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]
Can you advise on this parsing error and how to resolve it?
Also, from a developer process point of view, it would of course be best and least error prone if we can just pass the full contents of build/smart_contracts/TwoGarther.json
to the eth_contract
macro.
Thank you for also addressing these issues.