Category : smartcontracts

Macbook Pro : Monterey Intel Core i7 Brownie v1.17.2 I am learning solidity according to reference(https://www.youtube.com/watch?v=M576WGiDBdQ&t=25510s). What I tried to do here, is use brownie to deploy a contract(FundMe) in a script (deploy.py),then write a test script(test_can_fund_and_withdraw.py) The error occurs when I run the test script.I think it’s because in the testing script import the ..

Read more

I’m new to programming and currently following a brownie tutorial. While interacting with smart contracts, my tutor puts a tx.wait(1) after every transaction that requires a state change of the contract. I’m guessing tx.wait(1) means that we tell brownie to wait for at least one confirmation of the transaction before proceeding further. But tx.wait(1) is ..

Read more

I write the contract, pragma solidity >=0.7.0 <0.9.0; contract voteEXample{ event getVoterAndVoted(address voter,bytes32 voted); mapping(bytes32 => uint8) public receivedVotes; function vote(bytes32 toVote) public{ require(check(toVote)); receivedVotes[toVote] += 1; emit getVoterAndVoted(msg.sender,toVote); } } And through web3.py, I deployed the contract successfully. But, I failed in using the createFilter method. greeter = w3.eth.contract(address=address,abi = abi) transfer_filter = greeter.events.getVoterAndVoted.createFilter(fromBlock="0x0") ..

Read more

I’m trying to send a signed transaction from an interaction with a smart contract but it all falls apart when sending the raw transaction. My code is as follows import Globalvariables as thg bsc=’https://bsc-dataseed.binance.org/’ w3=Web3(Web3.HTTPProvider(bsc)) w3.middleware_onion.inject(geth_poa_middleware, layer=0) abi=json.loads(abi_string) contract_object=w3.eth.contract(address=w3.toChecksumAddress(thg.direction_market),abi=abi) nonce=w3.eth.getTransactionCount(w3.toChecksumAddress(thg.my_direction)) #tx={‘nonce’:nonce,’from’:w3.toChecksumAddress(thg.my_direction),’gasPrice’:50000000000,’gas’:277777} tx={‘nonce’:nonce,’from’:w3.toChecksumAddress(thg.my_direction),’maxFeePerGas’:277777,’maxPriorityFeePerGas’:30000} input_data={‘addresses’:[w3.toChecksumAddress(token[‘owner’]),w3.toChecksumAddress(token[‘nftContract’]),w3.toChecksumAddress(thg.contract_wbnb)], ‘values’:[int(token[‘tokenId’]),int(w3.toWei(token[‘bnb’],’ether’)),int(token[‘saltNonce’])], ‘signature’:bytes.fromhex(token[‘sign’].lstrip(‘0x’)) } purchase=contract_object.functions.matchTransaction(input_data[‘addresses’],input_data[‘values’],input_data[‘signature’]).buildTransaction(tx) sign_tx=w3.eth.account.sign_transaction(purchase,thg.metamask) print(sign_tx,type(sign_tx)) print(sign_tx.rawTransaction,type(sign_tx.rawTransaction)) try:raw_final=w3.eth.send_raw_transaction(sign_tx.rawTransaction) except:raw_final=w3.eth.send_raw_transaction(sign_tx.rawTransaction.hex()) The codes gives ..

Read more

I’m trying to replicate programmatically the action of purchasing a NFT from a Marketplace following what is in this contract 0x54ac76f9afe0764e6a8ed6c4179730e6c768f01c My goal is to be able to recreate a transaction like the following one with hash 0xa792fa25a9fcf9346cff4e37a580c96d27d019d646e815dcc8680496fd611adf First thing I did was to call that hash in Python with web3 which returned AttributeDict({‘blockHash’: HexBytes(‘0x778481abab6360ff6a13c6159743d9289d4edcee64c8fa2d067857fd3d0b673f’), ..

Read more

Hello! Help me please. I have just created own tokens on bsc testnet via PancakeFactory. Then I created liquidity pool with these tokens. I minted tokens and I want approve this tokens to PancakeRouter and add liquidity in this pool. You see my code below: def approves(w3, token_contract, router_contract, my_account, my_pk): allowance_value = token_contract.functions.allowance( my_account, ..

Read more

Help me, please! I don’t understand, why i can’t do approve from my token contract. I do so always and this code worked. But now I’ve got error. My code: def approves(w3, token_contract, router_contract, my_account, my_pk): allowance_value = token_contract.functions.allowance( my_account, router_contract.address).call() print(‘allowance_value: ‘, allowance_value) if allowance_value <= 1000000000000000: approve_est_gas = token_contract.functions.approve( router_contract.address, 100000000000000000000000 ).estimateGas( { ..

Read more