NAME
Web3::Tiny::Contract - Bind a Solidity contract's ABI to a live address
SYNOPSIS
my $erc20 = Web3::Tiny::Contract->new(
rpc => $rpc,
address => '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', # WETH
abi => {
symbol => { sig => 'symbol()', returns => ['string'] },
balanceOf => { sig => 'balanceOf(address)', returns => ['uint256'] },
transfer => { sig => 'transfer(address,uint256)', returns => ['bool'] },
},
);
my $symbol = $erc20->call('symbol');
my $bal = $erc20->call('balanceOf', $wallet->address);
my $tx_hash = $erc20->send($wallet, 'transfer', $to_address, '1000000000000000000');
DESCRIPTION
A deliberately small alternative to parsing full Solidity JSON ABIs: you describe just the methods you actually call, each as a canonical signature string plus its return types. call() runs a read-only eth_call and decodes the result; send() builds, signs (via a Web3::Tiny::Wallet), and broadcasts a transaction, auto-filling nonce/gas price/chain id/gas estimate from the node when not supplied.