Right now the API just use a simple key value inspired json file to store the diagram data, the file can be found at dist/src/api/urls2.json.
The format is {storage_key, compressed_diagramdata}
Reset db:
echo "{urls:[]}" > dist/src/api/urls2.json
$ npm run start
$ npm run build
$ npm run api
Note: If you want to enable webhooks, you need to set the enviromental variable:
$ export WEBHOOK_SITE_API_KEY =
/api/ink/contract_info
Description:
Get information from a deployed !ink contract on Rococo's Contracts chain.
input: contract's address and abi metadata, contract.json file
curl -X POST http://localhost:8080/api/ink/contract_info \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"abiJson": $(cat flipper.json),
"address": "5GLTeaqe8DqZbqhhzV6i2MdaG5zJbps84KwgjewUVo75gwga"
}
EOF
{"sucess":true,"description":[{"function_name":"flip","selector":"0x633aa551","mutates":true,"args":[]},{"function_name":"get","selector":"0x2f865bd9","mutates":false,"args":[]}]}
/api/info/preview
;Get generate preview information about scenario.
curl -XGET https://api.bagpipes.io/api/info/preview -d {scenario_id: 'scenario id goes here'}
{ info: "same info as /api/scenario/info", img: "base64 encoded image of the scenario" }
/api/scenario/info
;Get information about a scenario.
$ curl -X POST -H "Content-Type: application/json" -d '{"id": "Uvervffcw"}' http://localhost:8080/api/scenario/info
$ {"result":"assetHub > xTransfer > polkadot"}
/api/template/stats/<chain>
:curl http://127.0.0.1:8080/api/template/stats/assetHub
{"Amount":2}
curl http://127.0.0.1:8080/api/template/stats/polkadot
{"Amount":1}
/api/actions/query
:curl -X POST -H "Content-Type: application/json" -d '{"chain": "polkadot", "pallet_name": "timestamp", "method_name": "now", "params": []}' http://localhost:8080/api/actions/query
{"result":"1,716,394,878,001"}
/api/actions/generic-tx-gen
:Description:
curl -X POST -H "Content-Type: application/json" -d '{"chain": "polkadot", "pallet_name": "System", "method_name": "remark", "params": ["0xDEADBEEF"]}' http://localhost:8080/api/actions/generic-tx-gen
{"result":"0x2004000010deadbeef"}
/api/scenario/info/full
;Get full information about a scenario.
$ curl -X POST -H "Content-Type: application/json" -d '{"id": "Ts5hx-ng7"}' http://localhost:8080/api/scenario/info/full
{"result": "tx":"0xe804630903000100a10f0300010100f621771ddf37d482210b8c59617952eb1c2b40cfec55df47215231365186a057030400000000500000000000","summary":"polkadot > xTransfer > assetHub","asset":"0","amount":"20","source_chain":"polkadot","dest_chain":"assetHub","txtype":"xTransfer"}}
Note: replace Ts5hx-ng7
with your scenario id key.
{
"result": {
"tx": "0xe804630903000100a10f0300010100f621771ddf37d482210b8c59617952eb1c2b40cfec55df47215231365186a057030400000000500000000000",
"summary": "polkadot > xTransfer > assetHub",
"asset": "0",
"amount": "20",
"source_chain": "polkadot",
"dest_chain": "assetHub",
"txtype": "xTransfer"
}
}
TODO
/api/scenario/create
;Create a new scenario.
$ curl -X POST -H "Content-Type: application/json" -d '{"source_chain": "turing", "dest_chain": "moonriver", "destination_address": "my dest address goes here", "amount": 100, "assetid": 0}' http://localhost:8080/api/scenario/create
After your scenario id is generated, you can import it in the ui:
http://localhost:5173/#/create/?diagramData=MY_SCENARIO_ID
TODO
/api/xcm/asset-transfer
:Generate a raw xcm transaction.
curl -X POST http://127.0.0.1:8080/api/xcm/asset-transfer -H "Content-Type: application/json" -d '{
"sourchain": "polkadot",
"destchain": "assetHub",
"assetid": "0",
"amount": 1000000000,
"destinationaddress": "5GYdCV9F3gg9gnmWU8nrt8tXCxMXDbcGpsdX1gJStCx9yZKK"
}'
{"txdata":"0xf404630903000100a10f0300010100c63c1fb2c2d4a97b9aa07b951159b273e0d6a740914f71c074a93499d10e3e4503040000000002286bee0000000000"}
input:
The developer can then create their own frontend so that their user can sign the transaction. Thereafter, the transaction can be broadcast.
/api/hrmp/polkadot/openchannels
:Check what hrmp channels are avaliable for a parachain connected to polkadot.
curl -X POST -H "Content-Type: application/json" -d '{"paraid": 1000}' http://localhost:8080/api/hrmp/polkadot/openchannels
Input:
{"open_hrmp_channels":[1001,1002,2000,2004,2006,2007,2011,2012,2013,2030,2031,2032,2034,2035,2040,2046,2048,2051,2094,2101,2104],"sourcechain":1000}
input:
paraid = the paraid(as number) of the chain
Broadcast a transaction using author submit extrinsics.
curl -X POST -H "Content-Type: application/json" -d '{
"chain": "polkadot",
"tx": "0x91028400f2529946850f8dd66c794a795a6b01a911f25df007e4cf5f97f38a037380f2500114903d6caaa301dfc22a6d19df61ba38b547a70a492eb57bcdcb9298161b18562e13421b314c22a9e007c9e49583f77bb0faf7047f6456c78c5487225e1a8f84b500a50200630903000100a10f0300010100f2529946850f8dd66c794a795a6b01a911f25df007e4cf5f97f38a037380f25003040000000002286bee0000000000"
}' http://127.0.0.1:8080/api/chain/Broadcast
{"status":"broadcasted","hash":"0xf9b86cd2121c25685b5bbf9efffc5f6c81e7d3b568811860de36dccb09837d2b"}
input:
In order to test the broadcast feature a user must:
3: change the seedphrase to an account that has enough tokens to pay tx fee's in the get_test_acccount
function:
export function get_test_account() {
const e0 = new Keyring({ type: 'sr25519' });
const account = e0.addFromUri('SET SEEDPHRASE HERE');
return account;
}
// const bhash = await broadcastToChain('polkadot', testo);
// console.log(`blockhash published: `, bhash.toString());
tx_si start
generating tx..
route_tx start
polkadot:hydradx
handleTransfer for Polkadot to HydraDx...
cant connect
connect
drafting dot to hydradx
Creating tx
4
rawtx: 0xf404630803000100c91f0300010100f43376315face751ae6014e8a94301b2c27c0bc4a234e9997ed2c856d13d3d2f030400000000823801000000000000
Signature: 0x8d0284005400e2f7f5669b26998d8e4d3c1a2c8a2d0a9af827ca54a1cc3509105035c32e01286f7090ae34a1e3b8827ef9c035ede86a2b3e5c16bb6df072541327c7797d07e5934e245ae7c9ce199b2212fe559ff2df0a9ad1d66421aa3828223d8b2e9c8b45020400630803000100c91f0300010100f43376315face751ae6014e8a94301b2c27c0bc4a234e9997ed2c856d13d3d2f030400000000823801000000000000
Verfied tx: 0x8d0284005400e2f7f5669b26998d8e4d3c1a2c8a2d0a9af827ca54a1cc3509105035c32e01286f7090ae34a1e3b8827ef9c035ede86a2b3e5c16bb6df072541327c7797d07e5934e245ae7c9ce199b2212fe559ff2df0a9ad1d66421aa3828223d8b2e9c8b45020400630803000100c91f0300010100f43376315face751ae6014e8a94301b2c27c0bc4a234e9997ed2c856d13d3d2f030400000000823801000000000000
Copy the verified tx
and curl it to the broadcast api:
curl -X POST -H "Content-Type: application/json" -d '{
"chain": "polkadot",
"tx": "0x8d0284005400e2f7f5669b26998d8e4d3c1a2c8a2d0a9af827ca54a1cc3509105035c32e01286f7090ae34a1e3b8827ef9c035ede86a2b3e5c16bb6df072541327c7797d07e5934e245ae7c9ce199b2212fe559ff2df0a9ad1d66421aa3828223d8b2e9c8b45020400630803000100c91f0300010100f43376315face751ae6014e8a94301b2c27c0bc4a234e9997ed2c856d13d3d2f030400000000823801000000000000"
}' http://127.0.0.1:8080/broadcast
Result:
{"status":"broadcasted","hash":"0xf9b86cd2121c25685b5bbf9efffc5f6c81e7d3b568811860de36dccb09837d2b"}
$ curl https://api.xcmsend.com
{"success":true,"documentation":"https://xcmsend.github.io/api/index.html"}