I need to send USDT and other ERC-20 tokens via Geth on Ethereum. I'm using PHP and Web3.php library to work with Ethereum. So far, it worked well for everything. Now, I need to start sending tokens based on contracts.
In the official documents of Ethereum, it said about data parametere:
The compiled code of a contract OR the hash of the invoked method signature and encoded parameters
I thought I could use sendTransaction()
to send ERC-20 tokens directly, so I used the given USDT encoded ABI in the data
parameter, but it did not work. Then I came back to Web3.php project, and saw there are different codes for contracts like this:
use Web3\Contract;
$contract = new Contract('http://localhost:8545', $abi);
// deploy contract
$contract->bytecode($bytecode)->new($params, $callback);
// call contract function
$contract->at($contractAddress)->call($functionName, $params, $callback);
// change function state
$contract->at($contractAddress)->send($functionName, $params, $callback);
// estimate deploy contract gas
$contract->bytecode($bytecode)->estimateGas($params, $callback);
// estimate function gas
$contract->at($contractAddress)->estimateGas($functionName, $params, $callback);
// get constructor data
$constructorData = $contract->bytecode($bytecode)->getData($params);
// get function data
$functionData = $contract->at($contractAddress)->getData($functionName, $params);
Unfortunately, as I am new in contracts, I do not know which one of the codes above should be used for my project (Sending USDT). All of them? or just some of them?
And unfortunately, the provided document for the methods inside this section did not have details about used parameters! This made me more confused.
May you help me please?