出售代币并获得 BNB 而不是 wBNB?
Posted
技术标签:
【中文标题】出售代币并获得 BNB 而不是 wBNB?【英文标题】:Selling tokens and get BNB instead of wBNB? 【发布时间】:2022-01-01 21:15:45 【问题描述】:我制作了一个在 BSC 智能链中销售代币的功能。但是,我想直接在 BNB 中而不是 wBNB 中接收它。如何打开收到的 wBNB?
def sell_drdc(wallet_address, token_address, wallet_no):
if not is_approved(token_address):
approve(wallet_address, private_key)
erc20 = web3.eth.contract(token_address, abi=erc20Abi)
token_value = erc20.functions.balanceOf(wallet_address).call()
if token_value != 0:
pancakeswap2_txn = router.functions.swapExactTokensForTokensSupportingFeeOnTransferTokens (token_value, 0, [DRDC_Address, wbnb_contract], wallet_address, (int(time()) + 900)).buildTransaction(
'from': wallet_address,
'nonce': web3.eth.get_transaction_count(wallet_address),
)
signed_txn = web3.eth.account.sign_transaction(pancakeswap2_txn, private_key=private_key)
try:
tx_token = web3.eth.send_raw_transaction(signed_txn.rawTransaction)
web3.eth.waitForTransactionReceipt(tx_token, timeout=900)
display_success() # Just function that sends success message
update_text()
except ValueError:
display_error() # Just a function that sends the error
except UnboundLocalError:
sell_drdc(wallet_address, token_address, wallet_no) # Attempts to repeat if something goes wrong
【问题讨论】:
【参考方案1】:我设法看看出了什么问题,应该是
swapExactTokensForETHSupportingFeeOnTransferTokens
【讨论】:
以上是关于出售代币并获得 BNB 而不是 wBNB?的主要内容,如果未能解决你的问题,请参考以下文章