0

i am trying to use the web3py library to deploy and interact with a smart contract on the BNB Smart Chain Testnet. However, upon running the code attached, i get the Transaction Underprice error. Need help in this regard.

` `` w3 = Web3(Web3.HTTPProvider('https://data-seed-prebsc-2-s1.binance.org:8545')) w3.middleware_onion.inject(geth_poa_middleware, layer=0)

acct = Account.create()

compiled_sol = compile_source( ''' pragma solidity >0.5.0;

 contract Greeter {
    string public greeting;

    constructor() public {
       greeting = 'Hello';
    }

     function setGreeting(string memory _greeting) public {
               greeting = _greeting;
    }

    function greet() view public returns (string memory) {
         return greeting;
    }
}
 ''',
output_values=['abi', 'bin']

)

contract_id, contract_interface = compiled_sol.popitem()

bytecode = contract_interface['bin']

abi = contract_interface['abi']

w3.middleware_onion.add(construct_sign_and_send_raw_middleware(acct)) w3.eth.set_gas_price_strategy(fast_gas_price_strategy)

w3.middleware_onion.add(middleware.time_based_cache_middleware)

w3.eth.default_account = acct.address

Greeter = w3.eth.contract(abi=abi, bytecode=bytecode)

tx_hash = Greeter.constructor().transact({'gas': 20000, 'from': acct.address, 'chainId': 97})

tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)

`

0 Answers0