Skip to main content
Compose tasks can build, sign, and send Solana transactions using Gill, a lightweight Solana client library. Since Compose tasks run in a sandboxed environment, you’ll wire Gill’s RPC transport through the built-in fetch function so that all network activity remains auditable.

Setup

Install Gill in your Compose project:
Add your Solana RPC URL and keypair as secrets in compose.yaml:

Sandboxed RPC transport

Compose tasks cannot use the global fetch — all HTTP requests must go through the provided context.fetch. Create a transport adapter that Gill can use:
Then create an RPC client from the transport:
This pattern applies to any Solana library that accepts a custom transport or fetch function. The key requirement is routing all network calls through context.fetch so they’re recorded in Compose’s event logs.

Loading a keypair

Store your Solana keypair as a secret in the same JSON byte-array format used by the Solana CLI (the output of solana-keygen). Then load it in your task:

Building and sending a transaction

Here’s a complete example that fetches Bitcoin’s price, writes it to a Solana program, and stores the result in a collection:

What’s happening

  1. RPC setup — A sandboxed transport wraps context.fetch so Gill’s RPC calls go through Compose’s auditable network layer.
  2. Load signer — The keypair is loaded from a Compose secret and converted into a Gill transaction signer.
  3. Fetch off-chain data — The task fetches Bitcoin’s price from CoinGecko with built-in retry logic.
  4. Derive PDA — A Program Derived Address is computed from seeds so the on-chain program knows where to store the data.
  5. Build instruction — The instruction data is assembled: an 8-byte Anchor discriminator followed by the key and value.
  6. Sign and send — The transaction is created, signed, base64-encoded, and submitted to the Solana RPC.
  7. Store metadata — The price and transaction signature are persisted in a Compose collection for later retrieval.

Next Steps

Packages

Learn more about using npm packages in Compose tasks.

Collections

Store and query state across task runs.

Task Triggers

Trigger your Solana tasks via cron, HTTP, or on-chain events.

Secrets

Securely manage your Solana keypair and RPC URL.