Construction API

Write to the chain

The construction API facilitates actions such as generating and sending transactions to the chain. The available methods have been listed below.

Construction

Derive address from a public key

Method: POST

URL: /construction/derive

Sample Request:

{
    "network_identifier" :  {
            "blockchain" : "ont",
            "network" : "mainnet"
        },
    "public_key" : {
        "hex_bytes" : "<pubkey hex string>",
        "curve_type" : "secp256k1",
        "metadata" : {
            "type" : "hex"
        }
    }
}

In the type field, the two address formats supported are hex and base58. The two supported curve types are secp256k1 and edwards25519.

Sample Response:

{
    "address" : "<address>",
    "metadata" : {
         "type" : "hex"
    }
}

Create a metadata request

Method: POST

URL: /construction/preprocess

Sample Request:

{
    "network_identifier": {
        "blockchain": "ont",
        "network": "privatenet"
    },
    "operations": [
        {
            "operation_identifier": {
                "index": 0
            },
            "type": "transfer",
            "status": "",
            "account": {
                "address": "AGc9NrdF5MuMJpkFfZ3MWKa67ds6H2fzud"
            },
            "amount": {
                "value": "-1000000000",
                "currency": {
                    "symbol": "ONT",
                    "decimals": 9,
                    "metadata": {
                        "ContractAddress": "0100000000000000000000000000000000000000",
                        "TokenType": "Governance Token"
                    }
                }
            }
        },
        {
            "operation_identifier": {
                "index": 1
            },
            "related_operations": [
                {
                    "index": 0
                }
            ],
            "type": "transfer",
            "status": "",
            "account": {
                "address": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS"
            },
            "amount": {
                "value": "1000000000",
                "currency": {
                    "symbol": "ONT",
                    "decimals": 9,
                    "metadata": {
                        "ContractAddress": "0100000000000000000000000000000000000000",
                        "TokenType": "Governance Token"
                    }
                }
            },
            "metadata": {
                "gasLimit": 20000,
                "gasPrice": 2500
            }
        }
    ],
    "metadata": {
        "payer": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS"
    }
}

Sample Response:

{
    "options": {
        "amount": "1000000000",
        "decimals": 9,
        "fromAddr": "AGc9NrdF5MuMJpkFfZ3MWKa67ds6H2fzud",
        "gasLimit": 20000,
        "gasPrice": 2500,
        "payer": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS",
        "symbol": "ONT",
        "toAddr": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS"
    }
}

Fetch transaction creation metadata

Method: POST

URL: /construction/metadata

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  },
  "options": {
    "method": "transfer"
  }
}

Sample Response:

{
    "metadata": {
        "amount": "",
        "asset": "",
        "fromAddr": "",
        "gasLimit": "",
        "gasPrice": "",
        "payer": "",
        "toAddr": ""
    }
}

Field

Type

Description

amount

String

Transaction amount

asset

String

Asset type

fromAddr

String

from address

gasLimit

String

Gas limit, default value: 2000

gasPrice

String

Gas price, default value: 2500

payer

String

Default from address

toAddr

String

to address

Generate an unsigned transaction and signing payloads

Method: POST

URL: /construction/payloads

Sample Request:

{
    "network_identifier": {
        "blockchain": "ont",
        "network": "privatenet"
    },
    "operations": [
        {
            "operation_identifier": {
                "index": 0
            },
            "type": "transfer",
            "status": "",
            "account": {
                "address": "AGc9NrdF5MuMJpkFfZ3MWKa67ds6H2fzud"
            },
            "amount": {
                "value": "-1000000000",
                "currency": {
                    "symbol": "ONT",
                    "decimals": 9,
                    "metadata": {
                        "ContractAddress": "0100000000000000000000000000000000000000",
                        "TokenType": "Governance Token"
                    }
                }
            }
        },
        {
            "operation_identifier": {
                "index": 1
            },
            "related_operations": [
                {
                    "index": 0
                }
            ],
            "type": "transfer",
            "status": "",
            "account": {
                "address": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS"
            },
            "amount": {
                "value": "1000000000",
                "currency": {
                    "symbol": "ONT",
                    "decimals": 9,
                    "metadata": {
                        "ContractAddress": "0100000000000000000000000000000000000000",
                        "TokenType": "Governance Token"
                    }
                }
            },
            "metadata": {
                "gasLimit": 20000,
                "gasPrice": 2500
            }
        }
    ],
    "metadata": {
        "payer": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS"
    }
}

Sample Response:

{
    "unsigned_transaction": "00d1b8c16889204e000000000000c409000000000000ffe723aefd01bac311d8b16ff8bfd594d77f31ee7100c66b14092118e0112274581b60dfb6fedcbfdcfc044be76a7cc814ffe723aefd01bac311d8b16ff8bfd594d77f31ee6a7cc8516a7cc86c51c1087472616e736665721400000000000000000000000000000000000000010068164f6e746f6c6f67792e4e61746976652e496e766f6b650000",
    "payloads": [
        {
            "hex_bytes": "a4a88f45b51e7aa01eedd0db3a7d7aff0a6e641256f3e073e8dbabb19358513f",
            "address": "AGc9NrdF5MuMJpkFfZ3MWKa67ds6H2fzud",
            "signature_type": "ecdsa"
        }
    ]
}

Parse a transaction

Method: POST

URL: /construction/parse

Sample Request:

{
    "network_identifier": {
        "blockchain": "ont",
        "network": "privatenet"
    },
    "signed" : false,
    "transaction":"00d10534aa05c409000000000000204e000000000000ffe723aefd01bac311d8b16ff8bfd594d77f31ee7100c66b14092118e0112274581b60dfb6fedcbfdcfc044be76a7cc814ffe723aefd01bac311d8b16ff8bfd594d77f31ee6a7cc8516a7cc86c51c1087472616e736665721400000000000000000000000000000000000000010068164f6e746f6c6f67792e4e61746976652e496e766f6b650000"
}

Sample Response:

{
    "operations": [
        {
            "operation_identifier": {
                "index": 0
            },
            "type": "transfer",
            "status": "SUCCESS",
            "account": {
                "address": "AGc9NrdF5MuMJpkFfZ3MWKa67ds6H2fzud"
            },
            "amount": {
                "value": "-1000000000",
                "currency": {
                    "symbol": "ONT",
                    "decimals": 9,
                    "metadata": {
                        "ContractAddress": "0100000000000000000000000000000000000000",
                        "TokenType": "Governance Token"
                    }
                }
            }
        },
        {
            "operation_identifier": {
                "index": 1
            },
            "related_operations": [
                {
                    "index": 0
                }
            ],
            "type": "transfer",
            "status": "SUCCESS",
            "account": {
                "address": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS"
            },
            "amount": {
                "value": "1000000000",
                "currency": {
                    "symbol": "ONT",
                    "decimals": 9,
                    "metadata": {
                        "ContractAddress": "0100000000000000000000000000000000000000",
                        "TokenType": "Governance Token"
                    }
                }
            },
            "metadata": {
                "gasLimit": 20000,
                "gasPrice": 2500
            }
        }
    ],
    "signers": [],
    "metadata": {
        "payer": "Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS"
    }
}

Create a transaction using signatures

Method: POST

URL: /construction/combine

Sample Request:

In this sample request, the account AGc9NrdF5MuMJpkFfZ3MWKa67ds6H2fzud transfers 1 ONT to the account Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS, and the account Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS pays the transaction fee as the payer.

{
	    "network_identifier":  {
            "blockchain": "ont",
            "network": "testnet"
        },
        "unsigned_transaction":"00d1594606d2c409000000000000204e000000000000ffe723aefd01bac311d8b16ff8bfd594d77f31ee7100c66b14092118e0112274581b60dfb6fedcbfdcfc044be76a7cc814ffe723aefd01bac311d8b16ff8bfd594d77f31ee6a7cc8516a7cc86c51c1087472616e736665721400000000000000000000000000000000000000010068164f6e746f6c6f67792e4e61746976652e496e766f6b650000",
        "signatures":[
        		{
	        	"signing_payload":{
	        		"address":"Af6xrG7WB9wUKQ3aRDXnfba2G5DXjqejMS",
	        		"hex_bytes":"2b371f76afde8a543fd0a6a58f2578281b3517e96c2a811114ea4c78e362b221",
	        		"signature_type":"ecdsa"
	        	},
	        	"public_key":{
	        		"hex_bytes":"02263e2e1eecf7a45f21e9e0f865510966d4e93551d95876ecb3c42acf2b68aaae",
	        		"curve_type":"secp256k1"
	        	},
	        	"signature_type":"ecdsa",
	        	"hex_bytes":"3b52bc592bbba306ca9368e2808d6eb1d14fe0c3e2c801294bf8ebe3a994b464e6888038b6411a78428f9020b9f43c9dbcada7f77c0307b3ce9a410d8d2b6fa6"
        	},
        	{
	        	"signing_payload":{
	        		"address":"AGc9NrdF5MuMJpkFfZ3MWKa67ds6H2fzud",
	        		"hex_bytes":"2b371f76afde8a543fd0a6a58f2578281b3517e96c2a811114ea4c78e362b221",
	        		"signature_type":"ecdsa"
	        	},
	        	"public_key":{
	        		"hex_bytes":"03944e3ff777b14add03a76fd6767aaf4a65c227ec201375d9118d4e6b272494c7",
	        		"curve_type":"secp256k1"
	        	},
	        	"signature_type":"ecdsa",
	        	"hex_bytes":"a6f29359a94db9725ceafa37012abd3a02cff41fe1b3ca6fb0f4c58e86cd2e214567a5f29682cd4432404ecb8ded644bfb9324fe0eb746fe53097ffed13d11b1"
        	}
        ]
}

Sample Response:

{
    "signed_transaction": "00d1594606d2c409000000000000204e000000000000ffe723aefd01bac311d8b16ff8bfd594d77f31ee7100c66b14092118e0112274581b60dfb6fedcbfdcfc044be76a7cc814ffe723aefd01bac311d8b16ff8bfd594d77f31ee6a7cc8516a7cc86c51c1087472616e736665721400000000000000000000000000000000000000010068164f6e746f6c6f67792e4e61746976652e496e766f6b65000241403b52bc592bbba306ca9368e2808d6eb1d14fe0c3e2c801294bf8ebe3a994b464e6888038b6411a78428f9020b9f43c9dbcada7f77c0307b3ce9a410d8d2b6fa6232102263e2e1eecf7a45f21e9e0f865510966d4e93551d95876ecb3c42acf2b68aaaeac4140a6f29359a94db9725ceafa37012abd3a02cff41fe1b3ca6fb0f4c58e86cd2e214567a5f29682cd4432404ecb8ded644bfb9324fe0eb746fe53097ffed13d11b1232103944e3ff777b14add03a76fd6767aaf4a65c227ec201375d9118d4e6b272494c7ac"
}

Fetch the hash of a signed transaction

Method: POST

URL: /construction/hash

Sample Request:

{
    "network_identifier": {
        "blockchain": "ont",
        "network": "privatenet"
    },
    "signed_transaction":"00d1458813d9c409000000000000204e000000000000ffe723aefd01bac311d8b16ff8bfd594d77f31ee7100c66b14092118e0112274581b60dfb6fedcbfdcfc044be76a7cc814ffe723aefd01bac311d8b16ff8bfd594d77f31ee6a7cc8516a7cc86c51c1087472616e736665721400000000000000000000000000000000000000010068164f6e746f6c6f67792e4e61746976652e496e766f6b6500024140cb1e23e46a7e8e01563c64d7b5d9bf8022f549d411487156d55403ec7213f6cec49d413631d841852e493dca27e746977ea2ddd9e69906b8db7e71c3e15f7407232102263e2e1eecf7a45f21e9e0f865510966d4e93551d95876ecb3c42acf2b68aaaeac41409d15ed0d27224caecb55207b002f4a57846423bbe26764307e29704abfe4b327710c449531ac0f9ef621d864eab93a2ef373d2bc33027873c9466a30e748145f232103944e3ff777b14add03a76fd6767aaf4a65c227ec201375d9118d4e6b272494c7ac"
}

Sample Response:

{
    "transaction_hash": "cc45747a18862709f4ce50290ac331c94fb5ef6b608c36c90b00314884312b03"
}

Submit a signed transaction

Method: POST

URL: /construction/submit

Sample Request:

{
  "network_identifier": {
    "blockchain": "ont",
    "network": "mainnet"
  },
  "signed_transaction": "<signed tx hex>"
}

Sample Response:

{
  "transaction_identifier": {
    "hash": "<tx hash>"
  },
  "metadata": {}
}

Last updated