NEO blockchain, programming tutorials, Javascript — 3

館長
Blockchain Under The Hood
2 min readMay 13, 2018

Transfer Native Token (NEO/GAS) on the blockchain

neon-js

This is a series of how you can start to build a decentralized app on the top of NEO. Before moving forward, I will guide you the fundamental aspect before we get started.

I am a full-stack javascript developer and one of the contributors for NEO blockchain project.

How To Get Started

NEO blockchain, programming tutorials, Javascript — 1

Transfer Native Token (NEO/GAS)

const Neon = require('@cityofzion/neon-js')
const account = new Neon.wallet.Account('Your Private Key')
const toAddress = 'ALGJTQVoaPd4o6KWjw8mf6gEMz3Zr4nY9s'
Neon.api.default.sendAsset({
net: 'MainNet',
account: account,
intents: Neon.api.makeIntent({
GAS: 1,
NEO: 1,
}, toAddress),
})
.then(rpcResponse => {
...rpcResponse
})

Tip of the day

Native Token Transfer under the hood .

1. neon-js will make RPC(Remote Procedure Call) from NEO server and check the balance of this particular account before preceding.

2. neon-js will make construct a input that could be processed by the NEO RPC server

const address = 'ALGJTQVoaPd4o6KWjw8mf6gEMz3Zr4nY9s'
const intend = Neon.api.makeIntent({
GAS: 1,
NEO: 1,
}, toAddress)
The `intend` will output following[
{
assetId: '602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7',
value: 1.00000000,
scriptHash: 'b62084b659b3a3e1c3373f6915bf418fffdb4031'
},
{
assetId: 'c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b',
value: 1.00000000,
scriptHash: 'b62084b659b3a3e1c3373f6915bf418fffdb4031'
}
]

3. Finally, neon-js will use the privateKey that was given and sign the intent with it.

Stay Tune

I will show you how to transfer NEP5 token(NEO/GAS) for my next tutorial.

I make one post on every Monday UTC+0 time zone, but if I have more than 500 claps, I make another post immediately.

Feel free to drop message to me if you want to suggest a topic for me.

Useful Link

Blockchain Programing
1.「NEO blockchain, programming tutorials, Javascript — 1
2.「NEO blockchain, programming tutorials, Javascript — 2
3.「NEO blockchain, programming tutorials, Javascript — 3
4.「NEO blockchain, programming tutorials, Javascript — 4
5.「NEO blockchain, programming tutorials, Javascript — 5

Github
My Github

Neon-JS
NEON-JS-SDK

Blockchain Link List
Blockchain Posts List

About me
I am a full-stack javascript developer and one of the contributors for NEO blockchain project.

Build Decentralized Application with Javascript on the top of NEO?
NEO blockchain, programming tutorials, Javascript

If you consider yourself a talent?
Cobinhood Careers

--

--