Deploy a SCORE
In this document, we will explain various methods of deploying a SCORE onto the mainnet, and how to estimate the step limit for the deploy transaction.

Prerequisite

    Have an EOA account and the matching keystore file.
    ICX balance in your wallet.
    Understand the lifecycle of SCORE and the audit process. If you are not familiar with the concepts, please read SCORE Audit: Deploy Guideline.

Using T-Bears

To deploy a SCORE using T-Bears CLI, please follow the deploy guideline.

Using Python SDK

​Token Deploy Code Example on Python SDK.

Using Java SDK

​Token Deploy Code Example on Java SDK.

Using JavaScript SDK

​Token Deploy Code Example on JavaScript SDK.

Step Estimation for SCORE Deploy

The formula

Required steps for SCORE deploy is as follows.
    Installing SCORE = DEFAULT + INPUT + CONTRACT_SET + CONTRACT_CREATE
    Updating SCORE = DEFAULT + INPUT + CONTRACT_SET + CONTRACT_UPDATE
Where each term in the right side of the equation is calculated as;
    DEFAULT = 100_000
    CONTRACT_CREATE = 1_000_000_000
    CONTRACT_UPDATE = 1_600_000_000
    CONTRACT_SET = 30_000 * bytes of the SCORE zip file
    INPUT = 200 * bytes of the params.data field in the JSON RPC icx_sendTransaction request message
1
// Example INPUT data
2
"data": {
3
"contentType": "application/zip",
4
"content": "0x1867291283973610982301923812873419826abcdef91827319263187263a7326e...", // compressed SCORE data
5
"params": { // parameters to be passed to on_install()
6
"name": "ABCToken",
7
"symbol": "abc",
8
"decimals": "0x12"
9
}
10
}
Example
Suppose we have a SCORE zip file of 1,528 bytes in size, and the INPUT data size is 1,546 bytes. Required steps for installing the SCORE is;
1
Steps = DEFAULT + INPUT + CONTRACT_SET + CONTRACT_CREATE
2
= 100,000 + (1,546 * 200) + (1,528 * 30,000) + 1,000,000,000
3
= 100,000 + 309,200 + 45,840,000 + 1,000,000,000
4
= 1,046,249,200
5
= 0x3e5c7ef0

Step estimation using the JSON RPC API

​debug_estimateStep API will estimate the required steps of the given transaction. You can create the transaction data without stepLimit and signature, and pass it to the API endpoint <scheme>://<host>/api/debug/v3. The transaction is not added to the blockchain but simply returns the estimated steps. Sample request messages will look like the bellows.
    SCORE install
1
// Request message without stepLimit and signature
2
{
3
"jsonrpc": "2.0",
4
"method": "debug_estimateStep",
5
"id": 1234,
6
"params": {
7
"version": "0x3",
8
"from": "hxbe258ceb872e08851f1f59694dac2558708ece11",
9
"to": "cx0000000000000000000000000000000000000000", // address 0 means SCORE install
10
"timestamp": "0x563a6cf330136",
11
"nid": "0x3",
12
"nonce": "0x1",
13
"dataType": "deploy",
14
"data": {
15
"contentType": "application/zip",
16
"content": "0x1867291283973610982301923812873419826abcdef91827319263187263a7326e...", // compressed SCORE data
17
"params": { // parameters to be passed to on_install()
18
"name": "ABCToken",
19
"symbol": "abc",
20
"decimals": "0x12"
21
}
22
}
23
}
24
}
    SCORE update
1
// Request message without stepLimit and signature
2
{
3
"jsonrpc": "2.0",
4
"method": "debug_estimateStep",
5
"id": 1234,
6
"params": {
7
"version": "0x3",
8
"from": "hxbe258ceb872e08851f1f59694dac2558708ece11",
9
"to": "cxb0776ee37f5b45bfaea8cff1d8232fbb6122ec32", // SCORE address to be updated
10
"timestamp": "0x563a6cf330136",
11
"nid": "0x3",
12
"nonce": "0x1",
13
"dataType": "deploy",
14
"data": {
15
"contentType": "application/zip",
16
"content": "0x1867291283973610982301923812873419826abcdef91827319263187263a7326e...", // compressed SCORE data
17
"params": { // parameters to be passed to on_update()
18
"amount": "0x1234"
19
}
20
}
21
}
22
}