1

你好!请帮帮我。我刚刚通过 PancakeFactory 在 bsc 测试网上创建了自己的令牌。然后我用这些代币创建了流动资金池。我铸造了代币,我想批准这个代币给 PancakeRouter 并在这个池中增加流动性。

你在下面看到我的代码:


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,
            10000
        ).estimateGas(
            {
                'from': my_account,
                'nonce': w3.eth.get_transaction_count(my_account)
            }
        )

        approve_tx_builder = token_contract.functions.approve(
            router_contract.address,
            10000
        ).buildTransaction(
            {
                'from': my_account,
                'nonce': w3.eth.get_transaction_count(my_account),
                'gas': approve_est_gas
            }
        )

        signed_tx = w3.eth.account.sign_transaction(approve_tx_builder, my_pk)
        tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
        tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
        print('tx_hash: ', tx_receipt['transactionHash'].hex())
        print('tx_hash: ', tx_receipt['status'])


我总是收到这个错误:


raise ContractLogicError('execution reverted')
web3.exceptions.ContractLogicError: execution reverted

4

0 回答 0