Set Script
Transaction to create a smart account
Smart accounts have a custom script that defines how transactions should be validated. The script needs to be compiled by the node before it's broadcasted as a transaction.
Scripts are written in the Ride programming language.
1
{
2
"type": 13,
3
"version": 3,
4
"id": "BGUEn2TERW4nnAQuXYgJ3z6qp28ivk3kykb724wV7MZz",
5
"sender": "3MtHYnCkd3oFZr21yb2vEdngcSGXvuNNCq2",
6
"senderKeyType": "Ed25519",
7
"senderPublicKey": "4EcSxUkMxqxBEBUBL2oKz3ARVsbyRJTivWpNrYQGdguz",
8
"script": "base64:AQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmmsz2x",
9
"timestamp": 1519862400,
10
"fee": 500000000,
11
"proofs": [
12
"jxW9T2iUSQ68yv41Wj8JKb8HykwzKzbuHLBG6eySLaXk45rNbDo3zr2AS9bGMggrBZUUJQTFjKHeiD1q69pPUxY"
13
],
14
"height": 1248629
15
}
Copied!

Examples

Restrict account

1
match tx {
2
case t: TransferTransaction => false
3
case mt: MassTransferTransaction => false
4
case ss: SetScriptTransaction => false
5
case _ => sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
6
}
Copied!
The "Restrict Account" script disables transfers from the account, it also disables modifying the script. This means that any funds on the account can only be used for staking/leasing and paying transaction fees.

Binary schema

The binary data structure of the unsigned transaction.
V3 (current)
V1
#
Field Name
Type
Length
1
Transaction type
Byte (constant, value=4)
1
2
Version
Byte (constant, value=3)
1
3
Chain id
Byte
1
4
Timestamp
Long
8
5
Sender's key type
KeyType (Byte)
1
6
Sender's public key
PublicKey (Array[Byte])
32 | 33
7
Fee
Long
8
8
Script length (N)
Short
2
9
Script
Array[Byte]
N
    Script is the (binary) compiled script (without "base64:" prefix).
    Chain id can be obtained by taking the 2nd byte from the sender address.
    Each key type has a numeric id in addition to the reference from the JSON.
    Integers (short, int, long) have a big endian byte order.
#
Field Name
Type
Length
1
Transaction type
Byte (constant, value=4)
1
2
Version
Byte (constant, value=1)
1
3
Chain id
Byte
1
4
Sender's public key
PublicKey (Array[Byte])
32
5
Includes script
Boolean (Byte)
1
6
Script length (N)
Short
2
7
Script
Array[Byte]
N
8
Fee
Long
8
9
Timestamp
Long
8
If the transaction doesn't include a script, the script length and script should be omitted from the binary data.
    Script is the (binary) compiled script (without "base64:" prefix).
    Chain id can be obtained by taking the 2nd byte from the sender address.
    Each key type has a numeric id in addition to the reference from the JSON.
    Integers (short, int, long) have a big endian byte order.
Last modified 2mo ago
Copy link