NAME
Blockchain::Ethereum::ABI::Encoder - ABI utility for encoding ethereum contract arguments
VERSION
version 0.016
SYNOPSIS
Allows you to encode contract ABI arguments
my $encoder = Blockchain::Ethereum::ABI::Encoder->new();
$encoder->function('test')
# string
->append(string => 'Hello, World!')
# bytes
->append(bytes => unpack("H*", 'Hello, World!'))
# tuple
->append('(uint256,address)' => [75000000000000, '0x0000000000000000000000000000000000000000'])
# arrays
->append('bool[]', [1, 0, 1, 0])
# multidimensional arrays
->append('uint256[][][2]', [[[1]], [[2]]])
# tuples arrays and tuples inside tuples
->append('((int256)[2])' => [[[1], [2]]])->encode();
METHODS
append
Appends type signature and the respective values to the encoder.
%paramkey is the respective type signature followed by the value e.g. uint256 => 10
Returns $self
function
Appends the function name to the encoder, this is optional for when you want the function signature added to the encoded string or only the function name encoded.
$function_namesolidity function name e.g. for `transfer(address,uint256)` will be `transfer`
Returns $self
generate_function_signature
Based on the given function name and type signatures create the complete function signature.
Returns the function signature string
encode_function_signature
Encode function signature keccak_256/sha3
$signature(Optional) function signature, if not given, will try to use the appended function name
Returns the encoded string 0x prefixed
encode
Encodes appended signatures and the function name (when given)
Usage:
encode() -> encoded string
Returns the encoded string, if function name was given will be 0x prefixed
AUTHOR
Reginaldo Costa <refeco@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2022 by REFECO.
This is free software, licensed under:
The MIT (X11) License