Can I transfer tokens from an ERC20 contract using

2019-06-14 07:17发布

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.

The actual contract code

Sending is not working unless the account is on Metamask

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?

Thanks for your help.

1条回答
Summer. ? 凉城
2楼-- · 2019-06-14 07:28

Yes, you can, I have written a ERC20 library for PHP.

https://www.furqansiddiqui.com/libraries/erc20-php/

https://github.com/furqansiddiqui/erc20-php

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.

There are other ERC20 standard methods included as well, such as name(), balanceOf(), decimals(), symbol()

查看更多
登录 后发表回答