web3.py + simpleCollectible "ContractLogicError" #949
-
Hi Everybody, I've deployed a "simpleCollection" contract from the NFT chapter and I'm trying to build the "createCollectible" transaction using web3.py but I'm getting "ContractLogicError". sample_token_uri = 'https://ipfs.io/ipfs/Qmd9MCGtdVz2miNumBHDbvj8bigSgTwnr4SbyH6DNnpWdt?filename=0-PUG.json'
###Get the abi
with open("api/compiled_contracts/SimpleCollectible.json", "r") as file:
simple_storage_file = json.loads(file.read())
abi = simple_storage_file['abi']
##RINKEBY connection
w3 = Web3(Web3.HTTPProvider(os.getenv("RINKEBY_RPC_URL")))
chain_id = 4
my_address = os.getenv("PUBLIC_KEY")
private_key = os.getenv("PRIVATE_KEY")
# Get the latest transaction
nonce = w3.eth.getTransactionCount(contract_address)
#Get the contract
simple_storage = w3.eth.contract(address=contract_address, abi=abi)
#Create transaction
create_simple_collectible = simple_storage.functions.createCollectible(sample_token_uri).buildTransaction(
{
"chainId": chain_id,
"gasPrice": w3.eth.gas_price,
"from": my_address,
"nonce": nonce,
}
) The contract: // SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract SimpleCollectible is ERC721 {
uint256 public tokenCounter;
constructor () public ERC721 ("Dogie", "DOG"){
tokenCounter = 0;
}
function createCollectible(string memory tokenURI) public returns (uint256){
uint256 newTokenId = tokenCounter;
_safeMint(msg.sender, newTokenId);
_setTokenURI(newTokenId, tokenURI);
tokenCounter = tokenCounter + 1;
return newTokenId;
}
}
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello @Willfromtoronto I see you are trying to deploy with plain web3 instead of brownie, so could you please share a screenshot with the whole error log ,and also share your folder structure? |
Beta Was this translation helpful? Give feedback.
-
This is the Cytools error, you can see info about how to solve this here. |
Beta Was this translation helpful? Give feedback.
This is the Cytools error, you can see info about how to solve this here.