Dive into Nebulas 4— Transactions

Roy Shang
Roy Shang
May 19, 2018 · 5 min read

All interactions in blockchains are achieved through transactions. In this post, I’ll share what transactions in Nebulas look like and how to submit transactions in different situations.


In Nebulas, we have three kinds of transactions: binary, deploy and call. Binary transactions are used to transfer tokens between accounts. Deploy transactions are used to deploy a smart contract. Call transactions are used to call functions in a deployed smart contract.

All transactions consist of 5 core parts: from/to, value, nonce, data, gas price/gas limit and signature.


From is always the sender’s address of the transaction. Otherwise, to differs in different transactions.

  1. Binary: to is the receiver of the tokens.
  2. Deploy: to is same as From.
  3. Call: to is the address of the smart contract to be called.


Value is the count of tokens to be transferred. In Nebulas, 1 Wei equals 1 token and 1 NAS equals 10¹⁸ tokens.


The nonce is designed to prevent replay attacks. For a given account, only after its transaction with nonce N is accepted, will its transaction with nonce N+1 be processed. Thus, we have to check the latest nonce of the account on chain before preparing a new transaction.

For example, we can use the following request to check current state of the account.

The latest nonce of the account is 1. If we want to submit a new transaction using this account, the transaction should be with nonce 2.


Data consists of Type and Payload. Type is the type of the transaction, such as binary, deploy and call. Payload varies in different transactions.

  1. Binary: Payload can be any byte array within 128 bytes.
  2. Deploy: Payload should be a JSON string, which contains codes with 128k, type of codes and initial arguments.
  3. Call: Payload should be a JSON string, which contains function name and arguments.

Gas Price/Gas Limit

In Nebulas, the sender of every transaction will be charged a few tokens by miners. Therefore, the execution of transaction will consume some Gas like Ethereum. Gas Price is the count of tokens that the sender wants to pay for each Gas consumed. Gas Limit is the max count of tokens that the sender wants to pay for the execution of the transaction.

More details about how the gas is calculated can be found here.


In Nebulas, the sender should sign the transaction to prove it’s sent by him. This is the basis of trust.

Send Transaction

In this section, I’ll introduce three methods to submit transactions and the typical situation they will be used in.

Sign and Send

In this way, we can sign a transaction in an offline environment and then submit it to another online node. This is the safest method for everyone to submit a transaction without exposing your own private key to the Internet.

First, sign the transaction to get raw data. We offer three methods to make it now.

Use Web-Wallet

Open the “Send Offline” page in Web-Wallet and choose the local net. Then fill in your address and inquire the information to check the state of your account.

Select your keystore file and unlock it with your passphrase. Everything happens locally so you don’t need to worry about security. You can even do this with your network disconnected to make sure your private key is safe.

Fill in the “To Address” and “Value/Amount to Send”, then generate the transaction to get the raw data of the signed transaction.

Use Local Node

Start your own node following this article and send the request as below.

Use Neb.js

Make sure you include nebulas.js in your page and run the following commands.

The result is different from the first one because the TIMESTAMP is not same.

Then, send the raw data to an online Nebulas node.

Send with Passphrase

If you trust a Nebulas node so much that you can delegate your keystore files to it, the second method is a good fit for you.

First, upload your keystore files to the keydir folders in the trusted Nebulas node.

Then, send the transaction with your passphrase.

Use Local Node

Upload your keystore files to the keydir folders in your trusted remote node. Then send the request with your passphrase as below.

Use Neb.js

Upload your keystore files to the keydir folders in your trusted remote node. Then send the request with your passphrase as below.

Send Directly

This is the most dangerous method. You probably shouldn’t use it unless you you have complete trust in the receiving Nebulas node.

First, upload your keystore files to the keydir folders in the trusted Nebulas node.

Then unlock your accounts with your passphrase for a given duration in the node. The unit of the duration is nano seconds(300000000000=300s).

After unlocking the account, everyone is able to send any transaction directly within the duration in that node without your authorization.

What’s Next?

I hope this helped you to understand the different methods for sending transactions on Nebulas, so you can choose the right one that works for you. Next, I’ll explain how to deploy and call a smart contract in Nebulas.


Nebulas is an autonomous metanet.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store