I created a basic MintableToken
with OpenZeppelin framework but I have lost my source code. I want to mint more of my tokens and I am trying to do so through web3.py
Here is my current code
web3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/MYAPI"))
web3.eth.defaultAccount = 'MYACC_ADDR'
abi = [
{
"constant": False,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_amount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": False,
"stateMutability": "pure",
"type": "function"
}
]
address = web3.toChecksumAddress('CONTRACT_ADDR') # FILL IN YOUR ACTUAL ADDRESS
contract = web3.eth.contract(address=address, abi=abi)
print(contract.functions.mint('MYACC_ADDR', 200).call())
Running this code via python3 mint.py
prints True
, but the contract isn't actually called. Any tips?
"stateMutability": "pure"
That's wrong and means that by default web3.py
will make a local call to a node instead of sending an actual transaction.
I believe it should be this instead:
"stateMutability": "nonpayable"
Of course, after that change note that you'll need to provide web3.py
with a from
address and a private key to sign the transaction with.