如何根据我的坚固合同中的付款使用我的ERC20自定义令牌?
我创建了一个自定义的ERC20令牌,目前已在TestNet上部署,将来会在Polygon上启动它。
固体性
uint256 public cost = 0.001 ether;
function test(uint256 _mintAmount) public payable {
require(msg.value >= cost * _mintAmount);
//some code
}
我想使用我的自定义令牌代替以太币。我该怎么做?有什么直截了当的方法吗?如果要使用react dapp,我该怎么做? 目前,对于以太坊,我的React Dapp被配置为以下内容 -
"WEI_COST": 1000000000000000,
请帮助。
I have created a custom ERC20 token and that is currently deployed on testnet and will launch it on polygon in future.
Solidity
uint256 public cost = 0.001 ether;
function test(uint256 _mintAmount) public payable {
require(msg.value >= cost * _mintAmount);
//some code
}
I want to use my custom token in place of ether. How do I do it? Is there any straight forward way for it? And if want to use a react dapp how may I do that?
Currently for Ethereum, my react dapp is configured as follow-
"WEI_COST": 1000000000000000,
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以与
IERC20
接口进行交互,该接口允许您处理ERC20令牌。为了解决您的问题,您可以看到此智能合同代码:我为您做了更好的理解记录。
注意:当您调用
readittoken()
功能时,请记住批准
您的智能合约以允许其在钱包中访问并传输令牌。You can interact with
IERC20
interface that allows you to handle ERC20 token. To solve your issue you can see this smart contract code:I put some notes for understand to you better what I done.
Attention: When you'll call
depositToken()
function remember toapprove
your smart contract for give it permission to access in your wallet and transfer the tokens.您可以批准智能合约来转让您的自定义令牌。
//批准智能合约转移令牌
token.approve(地址(this),_Amount);
You can approve the smart contract to transfer your custom token.
//approving smart contract to transfer token
token.approve(address(this), _amount);