Simple node Express API that comes with gill based on @solana/kit.
Clone the repo:
git clone https://github.com/solana-developers/solana-templates
cd solana-templates/node-express-canvacord-canvacord
Install dependencies:
pnpm install
Set up the keypair signer (one time per machine):
pnpm run setup
Start the api:
pnpm run dev
Build the api:
pnpm run build
The artifacts will be in the dist
directory. You can now run the api using npm run start
or node dist/index.js
.
Build the Docker image:
pnpm run docker:build
Run the Docker image:
pnpm run docker:run
The following environment variables can be used to configure the API:
SOLANA_RPC_ENDPOINT
: The Solana RPC endpoint to use. Defaults todevnet
.SOLANA_SIGNER_PATH
: The path to the keypair signer file. Defaults to./keypair-signer.json
.CORS_ORIGINS
: A comma-separated list of allowed origins for CORS. Defaults to*
.
Below are some examples of how to use the API using curl
. You can use jq to format the output.
This command will return the balance of the provided address.
curl http://localhost:3000/balance/FeeSoLT7WdoZVXsBPSZc7WKEuhVDVA1TKrNQoHacvxYm
This command will return the balance of the signer's address.
curl http://localhost:3000/balance-signer
This command will return the cluster based on the genesis hash of the connected cluster.
curl http://localhost:3000/cluster
This command will return the latest blockhash of the connected cluster. It uses a cached blockhash if available.
curl http://localhost:3000/latest-blockhash