问题描述
我正在使用带有Metamask的Web3开发网站,用户可以通过将ETH发送到地址来购买令牌.我想做的是,在接收到ETH之后,它将使用后端代码自动将令牌发送到用户ETH地址.
I'm developing a website using Web3 with Metamask, users can purchase tokens by sending ETH to an address.What I want to have done is that after the ETH is received it sends the tokens to the users ETH address automatically with backend code.
关于如何通过使用令牌指定地址的私钥来获取如何通过后端发送令牌的任何提示?
Any tips on how I can get it to send the tokens through the backend by specifying the private key of an address with tokens?
感谢您的帮助.
推荐答案
是的,可以,我已经为PHP编写了ERC20库.
Yes, you can, I have written a ERC20 library for PHP.
https://www.furqansiddiqui.com/libraries/erc20-php/
https://github.com/furqansiddiqui/erc20-php
要将ERC20令牌发送到地址,您需要做的就是使用"encodedTransferData"方法,并在发送以太坊交易时使用返回的字符串作为数据"参数的值.
To send ERC20 tokens to an address, all you need to do is use "encodedTransferData" method and use the returning string as value for "data" param when you send Ethereum transaction.
还包括其他ERC20标准方法,例如name(),balanceOf(),decimals(),symbol()
There are other ERC20 standard methods included as well, such as name(), balanceOf(), decimals(), symbol()
这篇关于我可以使用PHP从ERC20合同中转移代币吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!