Created
December 24, 2021 17:15
-
-
Save matthope1/e5618cbe5aff4f10fbde00f353921800 to your computer and use it in GitHub Desktop.
Ethers.js - How to add value to smart contract function call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To add funds to a function call you'll first need to have access to a contract instance | |
const contractInstance = new ethers.Contract(contractAddress, contractABI, signer) | |
# Then you'll need to create an object that will be passed into the smart contract as a parameter | |
# This object needs a key called value | |
# value needs to be a string representing wei (10^18 wei = 1 ether) | |
const overrides = { | |
value = "10000" | |
} | |
# Call the function on your smart contract & pass in overrides | |
# This function should be payable | |
cont txn = await contract.myFunction(arg1, arg2, overrides) | |
# This function call will start the transaction with the amount specified as value in our overrides object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TYPO line 13, cont -> const