callRaw method
Future<String>
callRaw({
- EthereumAddress? sender,
- required EthereumAddress contract,
- required Uint8List data,
- BlockNum? atBlock,
Sends a raw method call to a smart contract.
The connected node must be able to calculate the result locally, which
means that the call can't write any data to the blockchain. Doing that
would require a transaction which can be sent via sendTransaction.
As no data will be written, you can use the sender
to specify any
Ethereum address that would call that function. To use the address of a
credential, call Credentials.address.
This function allows specifying a custom block mined in the past to get historical data. By default, BlockNum.current will be used.
See also:
- call, which automatically encodes function parameters and parses a response.
Implementation
Future<String> callRaw({
EthereumAddress? sender,
required EthereumAddress contract,
required Uint8List data,
BlockNum? atBlock,
}) {
final call = {
'to': contract.hex,
'data': bytesToHex(data, include0x: true, padToEvenLength: true),
if (sender != null) 'from': sender.hex,
};
return makeRPCCall<String>('eth_call', [call, _getBlockParam(atBlock)]);
}