Lets say I have a transaction like below:

var tx =     { transaction_id: 
      broadcast: false,
       { compression: 'none',
          { expiration: '2018-05-09T13:00:16',
            region: 0,
            ref_block_num: 19637,
            ref_block_prefix: 1895049749,
            max_net_usage_words: 0,
            max_kcpu_usage: 0,
            delay_sec: 0,
            context_free_actions: [],
            actions: [Array] },
         signatures: [] } }

Let's say const privateKey = 5KBwtUpu6qMKysaUXswjQr1b3Rhdza2EftAUFQPi6wZpUdkcY13

What is the specific process for signing this transaction? How are the fields encoded and what data is included in the transaction signature?

3 Answers 3


You can use eosjs-ecc for signing easily.

If you want to sign a hash:

ecc.Signature.signHash(sha256hash, privateKey).toString()

If you want to sign something that isn't a hash:

ecc.sign(Buffer.from(someData, 'utf8'), privateKey)

Edit: The transaction itself will have to be serialized based on the ABI, packed and then signed. eosjs uses fcbuffer for that.

  • Great! Thanks. I will try this as soon as I get home. :))
    – cookiekid
    May 9, 2018 at 22:29
  • But for signing an EOS Transaction, what is the input to the sign function? May 9, 2018 at 22:35
  • 1
    @JohnHaager so that's a bit more in-depth. The transaction itself will have to be serialized based on the ABI, packed and then signed. eosjs uses fcbuffer for that.
    – nsjames
    May 9, 2018 at 22:41
  • 1
    @nsjames That's good info. You should add it to your answer as it will help those who end up needing to implement transaction signing in languages other than JS. May 9, 2018 at 23:18
  • @nsjames wait... so this will not generate a valid signature so that the transaction can be pushed to the blockchain with the produced signature? Sorry, I can't try this for myself atm since I'm not at home.
    – cookiekid
    May 9, 2018 at 23:19

To sign a transaction offline you can use eosjs. There is a configuration option

broadcast [boolean=true] - post the transaction to the blockchain. Use false to obtain a fully signed transaction.

If you want to translate it to another language you need to convert the code from


I normally use it like this and eosjs signs it automatically.

eos.contract('currency').then(currency => {
 currency.transaction(cur => {
  cur.transfer('inita', 'initb', '1 CUR', '')

If you want to sign it yourself i guess you should use eosjs-ecc

  • 1
    This still uses a third party api. I need to do it manually. I have seen eosjs-ecc but I am still unsure of what data actually needs to be signed. You can't sign an object unless it is converted to a string, buffer etc.
    – cookiekid
    May 9, 2018 at 13:41
  • 1
    To do that manually I would check the EOSRPC Wallet sign_transaction endpoint. But I suggest you to have an instance of keosd and let it handle your keys, you could just call the sign_transaction out-of-the-box! May 9, 2018 at 14:22
  • 2
    "This still uses a third party api". Does this mean you want to sign without using any existing library? If so maybe you should drop "eosjs" from the title. May 9, 2018 at 19:17
  • No, sorry for confusion. I mean that using nanonano's method requires that you connect to a node. It has to be done without needing to.
    – cookiekid
    May 9, 2018 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.