Closed nathanielajayi7 closed 3 years ago
Do you means, you want transfer ETH?
Yes. That's what I mean specifically
And how do I know a transaction was successful?
Yes, you can use TransactionBuilder
class.
Sample usage:
use Lessmore92\Ethereum\Foundation\Transaction\TransactionBuilder;
use Lessmore92\Ethereum\Token;
$nonce = '04';
$gasPrice = '03f5476a00';
$gasLimit = '027f4b';
$to = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';
$value = '2a45907d1bef7c00';
$privateKey = 'b2f2698dd7343fa5afc96626dee139cb92e58e5d04e855f4c712727bf198e898';
$for_web3_client = new Token("", "https://mainnet.infura.io/v3/API_KEY");
$tx = (new TransactionBuilder())
->setEth($for_web3_client->getEth())
->to($to)
->nonce($nonce)
->gasPrice($gasPrice)
->gasLimit($gasLimit)
->data('')
->amount($value)
->build()
;
//to get signed tx hash
echo $tx->sign($privateKey)
->getSignedHash()
;
//to send signed tx hash
$tx->sign($privateKey)
->send()
;
After call send
method $tx->sign($privateKey)->send()
if tx_id returns that means transaction was successful.
To be sure, all variables are hexadecimal?
yes
Is it possible to use this library to initialize a transaction in ETH without passing a specific token or contract address?