Skip to content
LaksaRuby -- Zilliqa Blockchain Library
Branch: master
Clone or download
nickcen Merge pull request #4 from poctek/master
Add google protobuf gem
Latest commit 41ed1cb May 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin create KeyTool Jan 19, 2019
lib fixed #3 May 16, 2019
test fixed #3 May 16, 2019
.gitignore create KeyTool Jan 19, 2019
.travis.yml schnorr verify Jan 28, 2019
Gemfile create KeyTool Jan 19, 2019
Gemfile.lock Add google protobuf gem May 16, 2019
LICENSE.txt change license to GPL-v3 Mar 13, 2019
README.md Update README.md Mar 12, 2019
Rakefile create KeyTool Jan 19, 2019
laksa.gemspec Add google protobuf gem May 16, 2019

README.md

Laksa

Laksa -- Zilliqa Blockchain Ruby Library

The project is still under development.

Requirement

Ruby(2.5.3)

Installation

Add this line to your application's Gemfile:

gem 'laksa'

And then execute:

$ bundle

Or install it yourself as:

$ gem install laksa

Usage

Generate A new address

private_key = Laksa::Crypto::KeyTool.generate_private_key
public_key = Laksa::Crypto::KeyTool.get_public_key_from_private_key(private_key)
address = Laksa::Crypto::KeyTool.get_address_from_private_key(private_key)

Validate an address

address = '2624B9EA4B1CD740630F6BF2FEA82AAC0067070B'
Laksa::Util::Validator.address?(address)

Validate checksum address

checksum_address = '0x4BAF5faDA8e5Db92C3d3242618c5B47133AE003C'
Laksa::Util::Validator.checksum_address?(checksum_address)

Deploy and Call a transaction

private_key = "e19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930"

provider = Laksa::Jsonrpc::Provider.new('https://dev-api.zilliqa.com')
wallet = Laksa::Account::Wallet.new(provider)
address = wallet.add_by_private_key(private_key)

factory = Laksa::Contract::ContractFactory.new(provider, wallet)

contract = factory.new_contract(TEST_CONTRACT, [
  {
    vname: 'owner',
    type: 'ByStr20',
    value: '0x124567890124567890124567890124567890',
  },
],
ABI,
)

deploy_params = Laksa::Contract::DeployParams.new(nil, Laksa::Util.pack(8, 8), nil, 1000, 1000, nil)
tx, deployed = contract.deploy(deploy_params)    

assert tx.confirmed?
assert deployed.deployed?
assert_equal Laksa::Contract::ContractStatus::DEPLOYED, deployed.status

assert /[A-F0-9]+/ =~ contract.address

# call a deployed contract
call_tx = deployed.call(
      'setHello',
      [
        { vname: 'msg', type: 'String', value: 'Hello World!' },
      ],
      {
        version: Laksa::Util.pack(8, 8),
        amount: 0,
        gasPrice: 1000,
        gasLimit: 1000
      })


receipt = call_tx.tx_params.receipt

the definition of TEST_CONTRACT and ABI can be found in this folder.

You can’t perform that action at this time.