Skip to content

Instantly share code, notes, and snippets.

@svanas
Last active May 31, 2023 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svanas/35dceb33f64d6d2c12675e20b5631bcc to your computer and use it in GitHub Desktop.
Save svanas/35dceb33f64d6d2c12675e20b5631bcc to your computer and use it in GitHub Desktop.
Transferring ERC-20 tokens with Delphi
const ERC20 = TERC20.Create(TWeb3.Create(
Goerli.SetRPC('https://goerli.infura.io/v3/your-project-id')), // Goerli testnet
'0x45843aF56Aa1057eD1730cA5Ba3F709833900E77'); // TST smart contract address
try
ERC20.Transfer(
TPrivateKey('24622d680bb9d6d80c4d3fb4b4818e738de64b521948b1b1c85616eeeda54ee1'), // from private key
'0xaDDcedc01C1070bCE0aF7eb853845e7811EB649C', // to public key
1000000000000000, // 0.001 TST
procedure(hash: TTxHash; err: IError)
begin
TThread.Synchronize(nil, procedure
begin
if Assigned(err) then
MessageDlg(err.Message, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
else
MessageDlg(string(hash), TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], 0);
end);
end);
finally
ERC20.Free;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment