How to send an ETH address from a web page to a smart contract?

What's the best way to get the ETH address from a website form submission (php) passed to the smart contract so that the smart contract can send some new minted tokens to the ETH address collected in the php form?

The user sending the ETH address on the website does not have ETH, so we will have to pay for gas for any transactions.

The custom ETH address provided in php form is different from msg.sender (us).

Considered using PHP with: https://github.com/digitaldonkey/ethereum-php

But is there an easier approach? Thanks you

+3


source to share


1 answer


If you want to call a method using a smart contract, you need to sign and send a transaction. In your case, you want to sign the transaction from within PHP.

To sign a transaction you need



  • crpyto signature library
  • private key for an account that can invoke a contract and has ether
  • ability to encode contract method parameters

I don't know how to do this with PHP, but in JS you would use https://github.com/ethereumjs/ethereumjs-tx

+2


source







All Articles