Laksa -- Zilliqa Blockchain Ruby Library
The project is still under development.
Ruby(2.5.3)
Add this line to your application's Gemfile:
gem 'laksa'
And then execute:
$ bundle
Or install it yourself as:
$ gem install laksa
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)
address = '2624B9EA4B1CD740630F6BF2FEA82AAC0067070B'
Laksa::Util::Validator.address?(address)
checksum_address = '0x4BAF5faDA8e5Db92C3d3242618c5B47133AE003C'
Laksa::Util::Validator.checksum_address?(checksum_address)
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.