https://github.com/onflow/flow-account-api
https://github.com/onflow/flow-account-api
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/onflow/flow-account-api
- Owner: onflow
- License: apache-2.0
- Created: 2021-09-29T07:01:46.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-18T18:01:17.000Z (almost 4 years ago)
- Last Synced: 2025-04-27T22:32:57.347Z (7 months ago)
- Language: Go
- Size: 47.9 KB
- Stars: 4
- Watchers: 44
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flow Account API
This API is an intermediary for non-custodial Flow wallets. It has two responsibilities:
- Creating a new account on the behalf of a just-initialized wallet.
- Maintaining a registry of `publicKey` -> `accountAddress`.
## Running locally
This project uses Docker Compose and the Flow Emulator to simulate a blockchain environment
on a local machine.
Run this command to start the Docker Compose network:
```shell script
make run
```
### Run with emulator outside of Docker
Start the emulator using the `flow.json` file in this directory:
```shell script
flow emulator start
```
In a separate process, launch the API:
```shell script
make run-with-local-emulator
```
## API Routes
### Create Account
```shell script
curl --request POST \
--url http://localhost:8081/accounts \
--header 'content-type: application/json' \
--data '{
"publicKey": "6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b",
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256"
}
'
```
Sample response:
```json
{
"address": "01cf0e2f2f715450",
"publicKeys": [
{
"publicKey": "6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b",
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256"
}
]
}
```
### Get Account By Public Key
```shell script
curl --request GET \
--url 'http://localhost:8081/accounts?publicKey=6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b'
```
Sample response:
```json
{
"address": "01cf0e2f2f715450",
"publicKeys": [
{
"publicKey": "6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b",
"signatureAlgorithm": "ECDSA_P256",
"hashAlgorithm": "SHA3_256"
}
]
}
```