Skip to content

This is a basic example of Ark dApp development, by using our CustomTransaction approach with GTI and modular approach.

Notifications You must be signed in to change notification settings

learn-ark/dapp-custom-transaction-example

Repository files navigation

Imgur Test

ARK Core - dApp Installation Setup Steps

This is a basic example of Ark dApp development, by using our CustomTransaction approach with GTI and modular approach.

This Example is currently operational only on our core/develop branch!

This dApp enables a new transaction type on the ARK Core blockchain. New transaction types follows existing blockchain protocol.

Specification:

Purpose: Enables registration of a new business identity on the Core blockchain (with custom fields like name and website).

TransactionType: BusinessRegistration Fields:

  • name: string
  • website: string | uri

Registered Transaction is fully compatible with existing API (api/transactions/)

dApp Installation

STEP 1: Checkout This dApp Project As a GitSubmodule

cd plugins/ #location for loading of custom non-core dApps
git submodule add -f https://github.com/learn-ark/dapp-custom-transaction-example
cd dapp-custom-transaction-example

STEP 2: Load The dApp(Custom Transactions module) In The Corresponding Network Configurations.

Go to: core/packages/core/bin/testnet

cd packages/core/bin/config/testnet

Locate file plugins.js. We will add our plugin name to end of the list of the loaded plugins. This means that core will pickup the plugin/dapp and load it for a specific network configuration. Add line "@arkecosystem/custom-transactions": {}: to the end of the plugins.js file, so it looks something like this:

    "@arkecosystem/core-exchange-json-rpc": {
        enabled: process.env.CORE_EXCHANGE_JSON_RPC_ENABLED,
        host: process.env.CORE_EXCHANGE_JSON_RPC_HOST || "0.0.0.0",
        port: process.env.CORE_EXCHANGE_JSON_RPC_PORT || 8080,
        allowRemote: false,
        whitelist: ["127.0.0.1", "::ffff:127.0.0.1"],
    },
    "@arkecosystem/core-snapshots": {},
    "@arkecosystem/custom-transactions": {}, //our application hook (here we load the plugin/dapp)

STEP 3: Setup Development Docker Database

Setup docker database config and run Postgres DB via Docker. Follow the steps from here: https://learn.ark.dev/core-getting-started/spinning-up-your-first-testnet#step-1-start-docker-testnet-database

STEP 4: Start Local Testnet Blockchain

Start local blockchain with testnet running on your developer computer. Follow steps defined in here: https://learn.ark.dev/core-getting-started/spinning-up-your-first-testnet#step-2-testnet-network-boot

STEP 5: Send New Custom Transaction To The Local Node

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

curl --request POST \
  --url http://127.0.0.1:4003/api/v2/transactions \
  --header 'content-type: application/json' \
  --data '      {
                "transactions":
                [
                        {
                                "version": 2,
                                "network": 23,
                                "typeGroup": 1001,
                                "type": 100,
                                "nonce": "3",
                                "senderPublicKey":
                                 "03287bfebba4c7881a0509717e71b34b63f31e40021c321f89ae04f84be6d6ac37",
                                "fee": "5000000000",
                                "amount": "0",
                                "asset":
                                        { "businessData": { "name": "google", "website": "http://www.google.com" } },
                                "signature": "96583d6e4dcd9f35ceee38d37ba2e578a24a32bca2bf106f30e496840842f95e86aab471503852d097797bf2a14fbabd97a380b36b2e7fc20ba7d97e19175b48",
                                "id": "a6270e6e76093422fddd38ee3bad989f2b1eff8d32d3f5f6417ab0bc10da6e16" 
                        }
                ]
        }'

You should receive a response similar to this:

{
    "data": {
        "accept": ["b567325019edeef0ce5a1134af0b642a54ed2a8266a406e1a999f5d590eb5c3c"],
        "broadcast": ["b567325019edeef0ce5a1134af0b642a54ed2a8266a406e1a999f5d590eb5c3c"],
        "excess": [],
        "invalid": []
    }
}

Use Block Explorer To View Local Running Testnet

The following code instructions will run a local copy of ARK Explorer and connect to local node.

git clone https://github.com/arkecosystem/explorer
cd explorer

yarn install

yarn serve:testnet

After running yarn serve:testnet you should see the following:

DONE  Compiled successfully in 11030ms                                                                                                        11:07:14 AM

No type errors found
Version: typescript 3.6.3
Time: 6973ms

  App running at:
  - Local:   http://localhost:8080/
  - Network: http://192.168.0.178:8080/

  Note that the development build is not optimized.
  To create a production build, run yarn build.

Head over to http://localhost:8080/ to view contents of local running blockchain with Testnet environment setup.


Congrats, your dapp is loaded. Now look at the resources below to understand more about our dapp development.

About

This is a basic example of Ark dApp development, by using our CustomTransaction approach with GTI and modular approach.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •