Running The Example

This example dApp enables a new transaction type on the ARK Core blockchain. New transaction types follows existing blockchain protocol. You can fork or view full example code here:

Example Goal

Storyline: To develop and register a new business identity on the Core blockchain (with custom fields like name and website) we need to implement the supporting business logic in the form of a dApp enabling new transaction type called BusinessRegistration.

TransactionType name: BusinessRegistration

Custom Fields:

  • name: string
  • website: string | uri

When a custom transactions is registered it is fully compatible with existing API (api/transactions/) endpoints.

The same logic was used to build our core-magistrate transactions. You can check the source code here:


One of the best practices we encountered was splitting of the custom transaction logic into two separate packages: crypto and transactions.

This makes it easier to include in light-client application, where only payload generation is needed (the core-magistrate-crypto part), and the core protocol validation still remains in the main package (the core-magistrate-transaction package) on the core node.

STEP 1: Load And Run The Custom Transactions dApp

We assume that you already have local development environment setup. If not head over here:

Installation - Introduction

After successful setup of local development environment we need to add the plugin handle/name to the corresponding files. We need to add the handle “@arkecosystem/custom-transactions“ to the configuration file for each network configuration :

  • app.json in core/packages/core/bin/config/network-name/app.json

The How To Steps are explained in here:

Custom Transactions - Loading the dApp

STEP 2: Setup Development Docker Database

Setup docker database config and run Postgres DB via Docker. Follow the steps from here: Core Docker Setup

STEP 3: Start Local Testnet Blockchain

Start local blockchain with testnet running on your developer computer. Follow steps defined in here: [Spinning Up Your First Testnet](path’ => ’/docs/core/tutorials/testnet#step-2-testnet-network-boot)

STEP 4: Send New Custom Transaction To The Local Node

Send your new transaction type payload to the local blockchain node with the following curl command:

1curl --request POST \
2 --url \
3 --header 'content-type: application/json' \
4 --data ' {
5 "transactions":
6 [
7 {
8 "version": 2,
9 "network": 23,
10 "typeGroup": 1001,
11 "type": 100,
12 "nonce": "3",
13 "senderPublicKey": "03287bfebba4c7881a0509717e71b34b63f31e40021c321f89ae04f84be6d6ac37",
14 "fee": "5000000000",
15 "amount": "0",
16 "asset": { "businessData": { "name": "google", "website": "" } },
17 "signature": "809dac6e3077d6ae2083b353b6020badc37195c286079d466bb1d6670ed4e9628a5b5d0a621801e2763aae5add41905036ed8d21609ed9ddde9f941bd066833c",
18 "id": "b567325019edeef0ce5a1134af0b642a54ed2a8266a406e1a999f5d590eb5c3c"
19 }
20 ]
21 }'

You should receive a response similar to this:

2 "data": {
3 "accept": ["b567325019edeef0ce5a1134af0b642a54ed2a8266a406e1a999f5d590eb5c3c"],
4 "broadcast": ["b567325019edeef0ce5a1134af0b642a54ed2a8266a406e1a999f5d590eb5c3c"],
5 "excess": [],
6 "invalid": []
7 }

This means that transactions was accepted into the pool and broadcast to the rest of the network. If you want to create more transaction payloads, just use the BusinessTransactionBuilder to create and sign the payload data .

Last updated 2 years ago
Edit Page