Paramaters and useContractWrite #104
-
Hey everyone - have used ethers in the past and am using this now. I used to have a TSX code looks like the below - will also put contract abi. const contract = {...}
const [{ data: mintData, error: mintError, loading: mintLoading }, mint] = useContractWrite(
contract
'mint');
const doMint = () => {
const mintCost = (mintQty * 0.1).toString()
const cost = ethers.utils.parseEther(mintCost)
mint({ args: { value: cost, _qty: mintQty } }
);
};
{
"inputs": [
{
"internalType": "uint256",
"name": "_qty",
"type": "uint256"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Ok i got this working - but i think the types are wrong for overrides. Kind of looks like the types defined here - need to be type Config = {
args?: any | any[]
overrides?: PayableOverrides
} @tmm happy to PR if you want to confirm thats the case - guess we could also add an optional field to the useContractWrite to indicate if its payable or not and adjust the types accordingly? |
Beta Was this translation helpful? Give feedback.
Ok i got this working - but i think the types are wrong for overrides.
This is the code that works to call the function defined above, having the value not as an arg (per this example #49 (comment)) is what was throwing me - as that used to work when there were no other function arguments required
Kind of looks like the types defined here - need to be
[PayableOverrides](https://github.com/ethers-io/ethers.js/blob/master/packages/contracts/src.ts/index.ts#L17)
@tmm happy to PR if you want to confirm thats the case - guess we could also add an optional field to the useContractWrite to indicate if its payable or not and a…