Skip to content
CITA library for the Ruby language
Branch: develop
Clone or download
classicalliu Merge pull request #31 from cryptape/support-v2-tx
feat: add support for transaction v2
Latest commit 925625e May 22, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
cita-proto @ 6c11e06
lib feat: add support for transaction v2 May 22, 2019
secp256k1 @ 1e6f1f5 add secp256k1 as submodule & and to .travis.yml Sep 29, 2018
spec feat: add support for transaction v2 May 22, 2019
.pryrc add rubocop Oct 8, 2018
.rspec init project Sep 28, 2018
.rubocop.yml Rename to cita-sdk Jan 11, 2019
.travis.yml init project Sep 28, 2018
Gemfile Rename to cita-sdk Jan 11, 2019
Gemfile.lock feat: add support for transaction v2 May 22, 2019
Rakefile init project Sep 28, 2018
cita.gemspec Support ruby 2.6 Mar 4, 2019


Build Status Documentation



Add this line to your application's Gemfile:

gem 'cita-sdk-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cita-sdk-ruby


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

RPC calls RPC list

cita ="your url")

cita.rpc.get_block_by_number("0x0", true)
# or
cita.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 = CITA::TransactionSigner.encode(transaction, "you private key")

# you can unsign content by `decode` method
# you can set `recover` to false if you don't want to recover from address and public key
CITA::TransactionSigner.decode(content, recover: false)

send transaction

cita.rpc.send_transaction(transaction, private_key)

transfer tokens

cita.rpc.transfer(to: "to address", value: 1000, private_key: "your private key")


contract = cita.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])



  • support transaction version = 2
  • set default transaction version to 2


  • add getVersion and peersInfo RPC methods


  • support CITA v0.22


  • add recover option for decode transaction, for CITA v0.21 provide from in getTransaction rpc call
  • rename protobuf Crypto enum


  • rename to cita-sdk-ruby
  • rename top module name to CITA


  • 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.


  • supports CITA 0.19


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 cita-sdk-ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

You can’t perform that action at this time.