BenH70
BenH70

Reputation: 63

How to send an ETH address from a webpage to a smart contract?

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

The user submitting the ETH address on the website does not have any ETH so we will have to pay for the Gas for any transactions.

The user's ETH address submitted on the php form is different to the msg.sender address (us).

Have been considering using PHP with: https://github.com/digitaldonkey/ethereum-php

But is there an easier approach? Thank you

Upvotes: 4

Views: 1983

Answers (1)

gaiazov
gaiazov

Reputation: 1960

If you want to call a method on the smart contract, you have to sign and send a transaction. In your case you want to sign the transaction from inside PHP.

To sign a transaction you need

  • crpyto signing library
  • private key for an account that can call the contract and has ether
  • ability to encode contract method parameters

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

Upvotes: 3

Related Questions