-
KeyOptions
-
Type:
Properties:
Name |
Type |
Description |
salt |
Buffer
|
|
iv |
Buffer
|
|
kdf |
String
|
|
dklen |
Number
|
|
c |
Number
|
|
n |
Number
|
|
r |
Number
|
|
p |
Number
|
|
cipher |
String
|
|
uuid |
Buffer
|
|
-
Key
-
Key Object.
Type:
Properties:
Name |
Type |
Description |
version |
Number
|
|
id |
Buffer
|
|
address |
HexString
|
|
crypto |
Object
|
|
-
TransactionInit
-
Example
var acc = Account.NewAccount();
var tx = new Transaction({
chainID: 1,
from: acc,
to: "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17",
value: 10,
nonce: 12,
gasPrice: 1000000,
gasLimit: 2000000
});
-
Contract
-
Represent of smart contract payload data.
Type:
Properties:
Name |
Type |
Description |
source |
String
|
Contract source code for deploy contract. |
sourceType |
String
|
Contract source type for deploy contract. Currently support js and ts. |
args |
String
|
The params of contract. The args content is JSON string of parameters array. |
function |
String
|
The contract call function. |
binary |
Buffer
|
Binary contract representation. |
- See:
-
Example
// It's example of possible fields values.
// For deploy, and execute smart contracts follow this link - https://github.com/nebulasio/wiki/blob/master/tutorials/%5BEnglish%5D%20Nebulas%20101%20-%2003%20Smart%20Contracts%20JavaScript.md
{
'source': '"use strict";var DepositeContent=function(t){if(t){let n=JSON.parse(t);' +
'this.balance=new BigNumber(n.balance),this.expiryHeight=new BigNumber(n.expiryHeight)' +
'}else this.balance=new BigNumber(0),this.expiryHeight=new BigNumber(0)};' +
'DepositeContent.prototype={toString:function(){return JSON.stringify(this)}};' +
'var BankVaultContract=function(){LocalContractStorage.defineMapProperty(this,"bankVault",' +
'{parse:function(t){return new DepositeContent(t)},stringify:function(t){return t.toString()}})};' +
'BankVaultContract.prototype={init:function(){},save:function(t){var n=Blockchain.transaction.from,' +
'e=Blockchain.transaction.value,a=new BigNumber(Blockchain.block.height),r=this.bankVault.get(n);' +
'r&&(e=e.plus(r.balance));var i=new DepositeContent;i.balance=e,i.expiryHeight=a.plus(t),' +
'this.bankVault.put(n,i)},takeout:function(t){var n=Blockchain.transaction.from,' +
'e=new BigNumber(Blockchain.block.height),a=new BigNumber(t),r=this.bankVault.get(n);' +
'if(!r)throw new Error("No deposit before.");if(e.lt(r.expiryHeight))throw new Error("Can't takeout before expiryHeight.");' +
'if(a.gt(r.balance))throw new Error("Insufficient balance.");if(0!=Blockchain.transfer(n,a))throw new Error("transfer failed.");' +
'Event.Trigger("BankVault",{Transfer:{from:Blockchain.transaction.to,to:n,value:a.toString()}}),' +
'r.balance=r.balance.sub(a),this.bankVault.put(n,r)},balanceOf:function(){var t=Blockchain.transaction.from;' +
'return this.bankVault.get(t)}},module.exports=BankVaultContract;',
'sourceType': 'js',
'args': '[0]',
'function': 'save'
}
-
TransactionOptions
-
Represent Transaction parameters
Type:
Properties:
Name |
Type |
Argument |
Description |
options.chainID |
Number
|
|
Transaction chain id. |
options.from |
HexString
|
|
Hex string of the sender account addresss.. |
options.to |
HexString
|
|
Hex string of the receiver account addresss.. |
options.value |
Number
|
|
Value of transaction. |
options.nonce |
Number
|
|
Transaction nonce. |
options.gasPrice |
Number
|
|
Gas price. The unit is 10^-18 NAS. |
options.gasLimit |
Number
|
|
Transaction gas limit. |
options.contract |
Contract
|
<optional>
|
|
Example
{
chainID: 1,
from: "n1QZMXSZtW7BUerroSms4axNfyBGyFGkrh5",
to: "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17",
value: 10,
nonce: 12,
gasPrice: 1000000,
gasLimit: 2000000
}
-
Buffer
-
Binary data type
Type:
Example
<Buffer 5b ed 67 f9 9c b3 31 9e 0c 6f 6a 03 54 8b e3 c8 c5 2a 83 64 46 4f 88 6f> 24
-
Password
-
Client password or passphrase.
Type:
Example
"password0192837465DlK" || "It's my secret phrase"
-
HexString
-
Hex-string
Type:
Example
"n1QZMXSZtW7BUerroSms4axNfyBGyFGkrh5";
-
Base64
-
Base64 encoded string
Type:
Example
"OGQ5NjllZWY2ZWNhZDNjMjlhM2E2MjkyODBlNjg2Y2YwYzNmNWQ1YTg2YWZmM2NhMTIwMjBjOTIzYWRjNmM5Mg==";
-
Hash
-
Hex-string or Buffer hash.
Type:
Example
"n1QZMXSZtW7BUerroSms4axNfyBGyFGkrh5" || <Buffer 5b ed 67 f9 9c b3 31 9e 0c 6f 6a 03 54 8b e3 c8 c5 2a 83 64 46 4f 88 6f> 24;
-
UInt32
-
UInt32 Structure.
Type:
Example
10