⚠️ This demo is a work in progress.
This is a demonstration of a RESTful API that implements a simple custodial wallet service for the Flow blockchain.
- Single admin account (hot wallet)
- Create user accounts (using admin account)
- Send an arbitrary transaction from the admin account
- Send an arbitrary transaction from a user account
- Send fungible token withdrawals from admin account (FLOW, FUSD)
- Detect fungible token deposits to admin account (FLOW, FUSD)
- Send fungible token withdrawals from a user account (FLOW, FUSD)
- Detect fungible token deposits to a user account (FLOW, FUSD)
- View the fungible token balance of the admin account
- View the fungible token balance of a user account
- Set up admin account with non-fungible token collections (
NFT.Collection
) - Send non-fungible token withdrawals from admin account
- Detect non-fungible token deposits to admin account
- Set up a user account with non-fungible token collections (
NFT.Collection
) - Send non-fungible token withdrawals from a user account
- Detect non-fungible token deposits to a user account
- View the non-fungible tokens owned by the admin account
- View the non-fungible tokens owned by a user account
First, install the Flow CLI.
npm install
cp env.example .env
Use Docker Compose to launch Postgres and the Flow Emulator:
docker-compose up -d
npm run start
GET /v1/accounts
Example
curl --request GET \
--url http://localhost:3000/v1/accounts
[
{
"address": "0xf8d6e0586b0a20c7"
},
{
"address": "0xe467b9dd11fa00df"
}
]
GET /v1/accounts/{address}
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")
Example
curl --request GET \
--url http://localhost:3000/v1/accounts/0xf8d6e0586b0a20c7
{
"address": "0xf8d6e0586b0a20c7"
}
POST /v1/accounts
Example
curl --request POST \
--url http://localhost:3000/v1/accounts
{
"address": "0xe467b9dd11fa00df"
}
⚠️ Not yet implemented
POST /v1/accounts/{address}/transactions
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")
Body (JSON)
code
: The Cadence code to execute in the transaction- The code must always specify exactly one authorizer (i.e.
prepare(auth: AuthAccount)
)
- The code must always specify exactly one authorizer (i.e.
Example
curl --request POST \
--url http://localhost:3000/v1/accounts/0xf8d6e0586b0a20c7/transactions \
--header 'Content-Type: application/json' \
--data '{ "code": "transaction { prepare(auth: AuthAccount) { log(\"Hello, World!\") } }" }'
{
"transactionId": "18647b584a03345f3b2d2c4d9ab2c4179ae1b124a7f62ef9f33910e5ca8b353c",
"error": null,
}
Supported tokens:
FLOW
FUSD
GET /v1/accounts/{address}/fungible-tokens
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")
Example
curl --request GET \
--url http://localhost:3000/v1/accounts/0xf8d6e0586b0a20c7/fungible-tokens
[
{
"name": "flow"
},
{
"name": "fusd"
}
]
GET /v1/accounts/{address}/fungible-tokens/{tokenName}
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the fungible token (e.g. "flow")
Example
curl --request GET \
--url http://localhost:3000/v1/accounts/0xf8d6e0586b0a20c7/fungible-tokens/flow
{
"name": "flow",
"balance": "42.0"
}
⚠️ Not yet implemented
GET /v1/accounts/{v1/accounts/{address}/fungible-tokens}/fungible-tokens/{tokenName}/withdrawals
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the fungible token (e.g. "flow")
⚠️ Not yet implemented
GET /v1/accounts/{address}/fungible-tokens/{tokenName}/withdrawals/{transactionId}
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the fungible token (e.g. "flow")transactionId
: The Flow transaction ID for the withdrawal
POST /v1/accounts/{address}/fungible-tokens/{tokenName}/withdrawals
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the fungible token (e.g. "flow")
Body (JSON)
amount
: The number of tokens to transfer (e.g. "123.456")- Must be a fixed-point number with a maximum of 8 decimal places
recipient
: The Flow address of the recipient (e.g. "0xf8d6e0586b0a20c7")
Example
curl --request POST \
--url http://localhost:3000/v1/accounts/0xf8d6e0586b0a20c7/fungible-tokens/fusd/withdrawls \
--header 'Content-Type: application/json' \
--data '{ "recipient": "0xe467b9dd11fa00df", "amount": "123.456" }'
{
"transactionId": "18647b584a03345f3b2d2c4d9ab2c4179ae1b124a7f62ef9f33910e5ca8b353c",
"recipient": "0xe467b9dd11fa00df",
"amount": "123.456"
}
⚠️ Not yet implemented
⚠️ Not yet implemented
GET /v1/accounts/{address}/non-fungible-tokens
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")
Example
curl --request GET \
--url http://localhost:3000/v1/accounts/0xf8d6e0586b0a20c7/non-fungible-tokens
⚠️ Not yet implemented
GET /v1/accounts/{address}/non-fungible-tokens/{tokenName}
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the non-fungible token (e.g. "nba-top-shot-moment")
⚠️ Not yet implemented
GET /v1/accounts/{address}/non-fungible-tokens/{tokenName}/withdrawals
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the non-fungible token (e.g. "nba-top-shot-moment")
⚠️ Not yet implemented
GET /v1/accounts/{address}/non-fungible-tokens/{tokenName}/withdrawals/{transactionId}
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the non-fungible token (e.g. "nba-top-shot-moment")transactionId
: The Flow transaction ID for the withdrawal
⚠️ Not yet implemented
POST /v1/accounts/{address}/non-fungible-tokens/{tokenName}/withdrawals
Parameters
address
: The address of the account (e.g. "0xf8d6e0586b0a20c7")tokenName
: The name of the non-fungible token (e.g. "nba-top-shot-moment")
Body (JSON)
recipient
: The Flow address of the recipient (e.g. "0xf8d6e0586b0a20c7")