Skip to content

hanchon-live/evmosprotojs

Repository files navigation

EvmosProtoJs

A javascript library to interact with the evmos blockchain using http2/protobuf.

Requirements

  • Node v15.8.0

Installation

TODO: publish the pkg

yarn add @hanchon/evmosprotojs

Usage

Account

import { EvmosJS } from "@hanchon/evmosprotojs";
let lib = new EvmosJS('localhost:9090')
let accountResponse = await lib.getAccount(req.body.wallet.address)

/*
{
  address: 'evmos19s2k47r2ay782cfs0hcej87xmzg25pr2a6a03a',
  pubkey: 'CiECiLH1Mbh4cdvANylRhyVcrkugxLw3ynJhBbIUCv0OaRc=',
  pubkeyType: '/ethermint.crypto.v1.ethsecp256k1.PubKey',
  accountNumber: 0,
  sequence: 1,
  error: '',
}
*/

Message Send

import { EvmosJS } from "@hanchon/evmosprotojs";

let lib = new EvmosJS('localhost:9090')
let accountResponse = await lib.getAccount(req.body.wallet.address)

let msgSend = lib.messages.CreateMsgSend(req.body.wallet.address,
    req.body.destination,
    req.body.amount,
    req.body.denom)

let transaction = lib.messages.CreateTransaction(
    msgSend,
    '',
    '20',
    'aphoton',
    200000,
    'ethsecp256k1',
    req.body.wallet.pubkey,
    accountResponse.sequence,
    accountResponse.accountNumber,
    'evmos_9000-1',
)

Claiming module

import { EvmosJS } from "@hanchon/evmosprotojs";
let lib = new EvmosJS('localhost:9090')
let claims = await lib.getClaimRecords('evmos18453r3pzazr0da0nz6hxnp5qyh9a689lwm7z7e')
/*
{
    initial_claimable_amount: '10000',
    claims: [
        { action: 1, claimable_amount: '1471', completed: false },
        { action: 2, claimable_amount: '0', completed: true },
        { action: 3, claimable_amount: '1471', completed: false },
        { action: 4, claimable_amount: '1471', completed: false }
    ],
    address: 'evmos18453r3pzazr0da0nz6hxnp5qyh9a689lwm7z7e',
    error: ''
}
*/

Build locally

yarn install
yarn test
yarn build

Build Protofiles

npm install -g grpc-tools
./scripts/get_protofiles.sh
./scripts/get_proto_files.evmos.sh
./scripts/create_proto_file.sh

TODOs

  • Publish the npm pkg
  • Add more protobuf messages

About

Protobuf client for javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •