Support for interacting with Ethereum contracts using the geth RPC interface
=cut
use Moo;
use JSON::MaybeXS;
use Math::BigInt;
use Scalar::Util qw(looks_like_number);
use List::Util qw(first
BUILD {
my ($self) = @_;
my @decoded_json = @{decode_json($self->contract_abi // "[]")};
for my $json_input (@decoded_json) {
if ($json_input->{type} =~ /^function|event|construct
or$/) {
push(@{$self->contract_decoded->{$json_input->{name} // $json_input->{type}}}, $json_input->{inputs});
}
}
unless ($self->contract_decoded->{constructor}) {
ct::Helper::ImportHelper - ImportHelper
=cut
use JSON::MaybeXS;
=head2 to_hex
Auxiliar to get bytecode and the ABI from the compiled truffle json.
Parameters:
file path
Return:
{abi, byt
t = path($file)->slurp_utf8;
my $decoded_json = decode_json($document);
return {
abi => encode_json($decoded_json->{abi}),
bytecode => $decoded_json->{bytecode}};
}
1;
eger gasPrice )
Return:
New contract instance
=head1 NAME
Ethereum::RPC::Client - Ethereum JSON-RPC Client
=head1 SYNOPSIS
use Ethereum::RPC::Client;
# Create Ethereum::RPC::Client obj
ps://github.com/ethereum/wiki/wiki/JSON-RPC
=head1 DESCRIPTION
This module implements in PERL the JSON-RPC of Ethereum L<https://github.com/ethereum/wiki/wiki/JSON-RPC>
=head1 SEE ALSO
L<Bitcoin::
h the static items before the dynamic items in the encoded
data
=over 4
=item C<input_list> the json input from the abi data
=back
return the integer offset
=head2 get_hex_param
Convert paramete
ed)
=item event_params_size => numeric (required)
=back
Returns a json encoded object: https://github.com/ethereum/wiki/wiki/JSON-RPC#returns-42
=head2 invoke_deploy
Prepare a deploy transaction.
package Ethereum::RPC::Client;
use strict;
use warnings;
use Moo;
use JSON::MaybeXS;
use Mojo::UserAgent;
use Ethereum::RPC::Contract;
our $VERSION = '0.05';
has host => (
is => 'ro',
,
jsonrpc => '2.0',
params => (ref $_[0] ? $_[0] : [@_]),
};
my $res = $self->http_client->post($url => json => $obj)->result;
# https://eth.wiki/json-rpc/json-rpc-error
, error message: %s (%s)\n", $res->json->{error}->{code}, $res->json->{error}->{message}, $method)
if ($res->json->{error}->{message});
return $res->json->{result};
}
=head2 contract
Cre