flow-account-api

module
v0.0.0-...-9762c8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2021 License: Apache-2.0

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:

make run
Run with emulator outside of Docker

Start the emulator using the flow.json file in this directory:

flow emulator start

In a separate process, launch the API:

make run-with-local-emulator

API Routes

Create Account
curl --request POST \
  --url http://localhost:8081/accounts \
  --header 'content-type: application/json' \
  --data '{
	"publicKey": "6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b",
	"signatureAlgorithm": "ECDSA_P256",
	"hashAlgorithm": "SHA3_256"
}
'

Sample response:

{
  "address": "01cf0e2f2f715450",
  "publicKeys": [
    {
      "publicKey": "6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b",
      "signatureAlgorithm": "ECDSA_P256",
      "hashAlgorithm": "SHA3_256"
    }
  ]
}
Get Account By Public Key
curl --request GET \
  --url 'http://localhost:8081/accounts?publicKey=6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b'

Sample response:

{
  "address": "01cf0e2f2f715450",
  "publicKeys": [
    {
      "publicKey": "6b1523db40836078eb6f80f8d4f934f03725a4e66574815b5d2a9f2ba5dcf9c483fc1b543392f6ada01cc13790f996d0969ee6f9c8d9190f54dc31f44be0a53b",
      "signatureAlgorithm": "ECDSA_P256",
      "hashAlgorithm": "SHA3_256"
    }
  ]
}

Directories

Path Synopsis
cmd
pkg
pg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL