Ethereum-RPC-Client

 view release on metacpan or  search on metacpan

lib/Ethereum/RPC/Contract/Helper/ImportHelper.pm  view on Meta::CPAN

package Ethereum::RPC::Contract::Helper::ImportHelper;

use strict;
use warnings;

use Path::Tiny;

our $VERSION = '0.05';

=head1 NAME

    Ethereum::RPC::Contract::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, bytecode}

=cut

sub from_truffle_build {
    my $file = shift;

    my $document = path($file)->slurp_utf8;

    my $decoded_json = decode_json($document);

    return {
        abi      => encode_json($decoded_json->{abi}),
        bytecode => $decoded_json->{bytecode}};
}

1;



( run in 1.667 second using v1.01-cache-2.11-cpan-98e64b0badf )