10

pancakeswap swapexacttokensforeth怎么将wbnb转为bnb | 登链社区 | 技术问答

 2 years ago
source link: https://learnblockchain.cn/question/3006
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

5 pancakeswap swapexacttokensforeth怎么将wbnb转为bnb

用pancakeswap的 swapExactTokensForETH来实现代币换bnb,但代码结果是换到wbnb

以下两张图分别是我代码的和pancake上换的,发现就差了一个wbnb到bnb的转换:

代码执行的:
image.png

pancake上换的:
image.png

这最后一步该怎么弄?

最佳答案 2天前

你是在 Web3 代码中实现么? 那应该调用了不同的方法:

获取 BNB 的是:swapExactTokensForETH

获取WBNB 的是:swapExactTokensForToken

在 Solidity 合约的话,可以调用 WBNB 的 withdraw(_amount) 换成 BNB

swapExactTokensForETHswapExactTokensForETHSupportingFeeOnTransferTokens都试过了,我觉得应该是这行有问题:feePath = [token["address"], busdAddress, wbnbAddress]就是替换到wbnb就没有了,是不是话要再加一个bnb的地址呢?好像又没有地址...

Tiny熊 - 布道者
擅长:智能合约,以太坊 | 采纳率 40% | 回答于 2天前

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK