Save data on the blockchain with a DotWallet hosted account
This API lets developers store data on the blockchain using a hosted(custodial) wallet account provided by DotWallet. If the developer does not already have a DotWallet hosted wallet, one will be created in step one.
This feature is only supported on BSV.
Data will be saved in the OP_RETURN field of the bitcoin transaction.
Step 1:Query or create account address
If you don't already have a hosted account, this will create one for you and return the address. If you already have an account it will return the address.
-
Address: https://www.ddpurse.com/openapi/v2/get_hosted_account
-
Method:
POST
-
Header params:
Param | Type | Required | Description |
---|---|---|---|
appid | string | YES | Application ID |
appsecret | string | YES | Application secret key |
- Body params(JSON)
Param | Type | Required | Description |
---|---|---|---|
coin_type | string | YES | Example: "BSV". Currently only BSV is supported |
Success:
Note: "code" here is the error response code. 0 means success
{
"code": 0,
"msg": "ok",
"data": {
"coin_type": "BSV",
"address": "1Mfy9GfxTLePsgRJiBGa6jdTCbMXaPnXXL"
}
}
Step 2:Query account balance
Check your account balance before saving data to the chain. If your balance is too low, please transfer some BSV to your wallet address.
-
Address: https://www.ddpurse.com/openapi/v2/get_hosted_account_balance
-
Method:
POST
-
Header params:
Param | Type | Required | Description |
---|---|---|---|
appid | string | YES | Application ID |
appsecret | string | YES | Application secret key |
- Body params(JSON)
Param | Type | Required | Description |
---|---|---|---|
coin_type | string | YES | Example: "BSV". Currently only BSV is supported |
Success:
Note: "code" here is the error response code. 0 means success
{
"code": 0,
"data": {
"confirm": 2434,
"unconfirm": 0
},
"msg": "ok"
}
Return params description:
Param | Description |
---|---|
confirm | Coin balance confirmed on the blockchain |
unconfirm | Coin balance as yet unconfirmed on the blockchain |
Step 3:Save data to the blockchain
-
Method:
POST
-
Header params:
Param | Type | Required | Description |
---|---|---|---|
appid | string | YES | Application ID |
appsecret | string | YES | Application secret key |
- Body params(JSON)
Param | Type | Required | Description |
---|---|---|---|
coin_type | string | YES | Example: "BSV". Currently only BSV is supported |
data | string | YES | The data to store on the blockchain |
data_type | int | YES | The data type of the {data} param (0: string, 1: bitcoin rawhex script) |
Example:
{ "coin_type": "BSV", "data": "This is a test to put data on the blockchain.", "data_type": 0 }
Success:
Note: "code" here is the error response code. 0 means success
{
"code": 0,
"data": {
"tx_id": "4a0225f00d07cef1c48b9be9f1d55e598f37bcac57ab650606eed39829fea3a1",
"fee": 134
},
"msg": "ok"
}
Return params description:
Param | Description |
---|---|
tx_id | BSV txid (transaction ID) |
fee | Miner fee |