-
Notifications
You must be signed in to change notification settings - Fork 38
MOACTransaction
MOAC transaction format is as the following:
type txdata struct {
AccountNonce `json:"nonce" gencodec:"required"`
SystemContract `json:"syscnt" gencodec:"required"`
Price `json:"gasPrice" gencodec:"required"`
GasLimit `json:"gas" gencodec:"required"`
Recipient `json:"to" rlp:"nil"` // nil means contract creation
Amount `json:"value" gencodec:"required"`
Payload `json:"input" gencodec:"required"`
ShardingFlag `json:"shardingFlag" gencodec:"required"`
Via `json:"via" rlp:"nil"`
// Signature values
V `json:"v" gencodec:"required"`
R `json:"r" gencodec:"required"`
S `json:"s" gencodec:"required"`
}Send signed transaction to the network is a safe process for the users. The signing process is done through supported MOAC libraries, such as NodeJs, Java, Python.
In nodeJs chain3 library, the signing process can be performed using the signTransaction() in chain3/lib/utils/account.js.
Inputs
-
dataBuffer or Array or Object a transaction can be initiailized with either a buffer containing the RLP serialized transaction or an array of buffers relating to each of the tx Properties, listed in order below in the exmple. Or lastly an Object containing the Properties of the transaction like in the Usage example. For Object and Arrays each of the elements can either be a Buffer, a hex-prefixed (0x) String , Number, or an object with a toBuffer method such as Bignum-
data.chainIdNumber EIP 155 chainId - mainnet: 99, testnet: 101 -
data.gasLimitBuffer transaction gas limit -
data.gasPriceBuffer transaction gas price -
data.toBuffer to the to address -
data.nonceBuffer nonce number -
data.shardingFlagBuffer shardingFlag, 0 - global transaction, 1 - direct call to MicroChain -
data.viaBuffer VNODE via address for MicroChain, can be null for global transaction -
data.dataBuffer this will contain the data of the message or the call of a contract -
data.valueBuffer the amount of Moac sent, can be 0 for contract or direct call.
-
-
keyBuffer Private key of the source account
Returns
-
rawBuffer The raw rlp encoded transaction as byte array or a hex-prefixed (0x) String
Example
var rawTx = {
nonce: '0x00',
gasPrice: '0x09184e72a000',
gasLimit: '0x2710',
to: '0x0000000000000000000000000000000000000000',
value: '0x00',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
chainId: 101,
shardingFlag: 0
};
var signTx = chain3.signTransaction(rawTx, src["key"]);
chain3.mc.sendRawTransaction(signTx, function(err, hash) {
if (!err){
console.log("Succeed!: ", hash);
return hash;
}else{
console.log("Chain3 error:", err.message);
return err.message;
}
});Basics
DAPP Development*
- Move to MOAC
- MOAC Transaction Format
- MOAC JSON-RPC
- Chain3 JavaScript lib
- Chain3 Python lib
- Get Testnet MOAC
DAPP Examples
Information Websites
Connect to MOAC network