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/3.0
branch!
This dApp enables a new transaction type on the ARK Core blockchain. New transaction types follows existing blockchain protocol.
Purpose: Enable of adding business data on the Core blockchain (with custom fields like name and website).
TransactionType: BusinessData
Fields:
- name: string
- website: string | uri
Registered Transaction is fully compatible with existing API (api/transactions/)
If you already set up core environment you can skip Step 1 & 2
git clone https://github.com/arkecosystem/core
cd core
git checkout 3.0
Setup docker database config and run Postgres DB via Docker. You can setup docker by following steps below:
yarn docker ark
cd docker/development/testnet
docker-compose up postgres
or follow the steps in the following link: https://learn.ark.dev/core-getting-started/spinning-up-your-first-testnet#step-1-start-docker-testnet-database
cd plugins/ #location for loading of custom non-core dApps
git submodule add -f https://github.com/KovacZan/custom-transaction-core-v3
Go to:
core/packages/core/bin/testnet
cd packages/core/bin/config/testnet
Locate file app.json
. 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:
{
"package": "@arkecosystem/core-transaction-pool"
},
to the app.json
so it will look like this:
{
"core": {
"plugins": [
...
{
"package": "@arkecosystem/core-transactions"
},
{
"package": "@arkecosystem/core-magistrate-transactions"
},
{
"package": "custom-transaction-corev3"
},
{
"package": "@arkecosystem/core-transaction-pool"
},
...
]
},
Before we start our Local Testnet we must compile code, this is done with:
yarn setup
in core
directory.
For starting local blockchain go to:
cd packages/core/testnet
yarn full:testnet
you can find more information in the following link: https://learn.ark.dev/core-getting-started/spinning-up-your-first-testnet#step-2-testnet-network-boot
Send your new transaction type payload to the local blockchain node with the following curl
command:
curl --request POST \
--url http://localhost:4003/api/transactions \
--header 'content-type: application/json' \
--data '{
"transactions":
[
{
"version":2,
"network":23,
"typeGroup":1001,
"type": 0,
"nonce":"3",
"senderPublicKey":
"03287bfebba4c7881a0509717e71b34b63f31e40021c321f89ae04f84be6d6ac37",
"fee":"10000000",
"amount":"0",
"asset":{
"businessData":
{"name":"google","website":"https://google.com"}
},
"signature":
"5b8e412da6103bf6e8ee04771803495f4e1e65e38ef13e5618053fddca75c0a90c1ed515124c20f7bcba64fc38496754930f80e3bb85c9b206016960375e97c7",
"id":
"6dd8a22571acab801214f87dda9734f7050705d64d9c4ef9b24bb4d2ce489691"
}
]
}'
You should receive a response similar to this:
{
"data":{
"accept":["6dd8a22571acab801214f87dda9734f7050705d64d9c4ef9b24bb4d2ce489691"],
"broadcast":["6dd8a22571acab801214f87dda9734f7050705d64d9c4ef9b24bb4d2ce489691"],
"excess":[],
"invalid":[]
}
}
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.