Build Status Documentation

Nervos AppChain Ruby SDK


Add this line to your application's Gemfile:

gem 'appchain.rb', github: "cryptape/appchain.rb"

And then execute:

$ bundle

Or install it yourself as:

$ gem install appchain.rb


See keccak256, to_hex and other utils methods in AppChain::Utils module

rpc calls RPC list

appchain ="your url")

appchain.rpc.get_block_by_number("0x0", true)
# or
appchain.rpc.getBlockByNumber("0x0", true) 

sign and unsign

# make a Transaction object first
transaction =
  to: "8ff0f5b85fba9a6429e2e256880291774f8e224f",
  nonce: "e4f195c409fe47c58a624de37c730679",
  quota: 30000,
  valid_until_block: 1882078,
  data: "",
  value: "0x3e8",
  chain_id: "1",
  version: 1

# sign transaction with your private key
content = AppChain::TransactionSigner.encode(transaction, "you private key")

# you can unsign content by `decode` method

send transaction

appchain.rpc.send_transaction(transaction, private_key)

transfer tokens

appchain.rpc.transfer(to: "to address", value: 1000, private_key)


contract = appchain.contract_at(abi, contract_address)
# for rpc call (constant functions)
response = contract.call_func(method: :symbol)
# for rpc sendTransaction
response = contract.send_func(tx: tx, private_key: private_key, method: :transfer, params: [address, tokens])



  • supports CITA 0.19


  • supports CITA 0.20 and 0.19
  • set default transaction version to 1
  • update TransactionSinger.decode output type to hash with symbol keys
  • parse TransactionSinger.decode hash value to hex string if it's bytes.


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the appchain.rb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.