API Documentation
Heads up! We're currently working on a new version of our Garden API alongside revamped documentation. Stay tunedโfresh documentation is coming soon!
๐๏ธ Create Order
Create a new order
๐๏ธ Get Order
Retrieve the details of an order by its ID
๐๏ธ AuthToken
Get an auth token
๐๏ธ Subscribe to Orders
Subscribe to Orders
๐๏ธ Fill Order
Fill an order
๐๏ธ Assets
Get all the supported assets and chains
๐๏ธ Nonce
Get random nonce
Create Orderโ
Payloadโ
Field | Type | Description |
---|---|---|
sendAddress | string | Wallet address in source chain |
receiveAddress | string | Address where funds should be received in destination chain |
orderPair | string | The trading pair for the order (explained here) |
sendAmount | string | Amount to be sent in satoshi (sats) |
receiveAmount | string | Amount to be received in satoshi (sats) |
secretHash | string | Hash of the secret generated by the user, which the counterparty will use to lock their funds in the HTLC |
userWalletBTCAddress | string | BTC wallet address where funds should be redirected from the receive address |
The sendAmount
and receiveAmount
must be in their lowest denominations. For example, if you want to send 0.001
Bitcoin then the sendAmount
would be 100000
SATS.
Authentication:
Include an Authorization
header with your request. Learn how to obtain an auth token here.
Garden charges 0.3% as the swap fees. Fee is calculated as the difference between the input and output amounts, which should be greater than or equal to 0.3% of the input amount.
Responseโ
Field | Type | Description |
---|---|---|
orderID | uint | ID of the created order |
Example payload
{
"sendAddress": "",
"receiveAddress": "",
"orderPair": "bitcoin:primary-ethereum:0xa5e38d098b54c00f10e32e51647086232a9a0afd",
"sendAmount": "100000",
"receiveAmount": "99700",
"secretHash": "",
"userWalletBTCAddress": ""
}
Get Orderโ
Order Objectโ
- Initiator: The party who creates the order.
- Follower: The party who accepts the order, also known as the counterparty or Filler.
Field | Type | Description |
---|---|---|
maker | string | Address of the maker who created the order |
taker | string | Address of the taker who accepted the order |
orderpair | string | The trading pair for the order (here) |
initiatoratomicswapid | uint | ID of the initiator's atomic swap |
followeratomicswapid | uint | ID of the follower's atomic swap |
initiatoratomicswap | *atomicswap | Details of the initiator's HTLC |
followeratomicswap | *atomicswap | Details of the follower's HTLC |
secrethash | string | Hash of the secret generated by the initiator, which the initiator and follower will use to lock their funds in the HTLC |
secret | string | The secret generated by the initiator, revealed during redemption process |
price | float64 | The price ratio of the initiator's atomic swap amount to the follower's atomic swap amount |
status | uint | The current status of the order |
secretnonce | uint64 | A count of the user's number of orders, used as a nonce to generate secrets |
userbtcwalletaddress | string | User's BTC wallet address |
AtomicSwap Objectโ
Field | Type | Description |
---|---|---|
status | uint | The current status of the atomic swap |
secretHash | string | Hash used in the HTLC to lock the funds |
secret | string | Secret used to unlock the HTLC, revealed during the redemption process |
onChainIdentifier | string | On-chain identifier for the generated HTLC |
initiatorAddress | string | Address of the initiator providing funds into the HTLC. |
redeemerAddress | string | Address where funds will be transferred if the HTLC is successfully unlocked. |
timelock | string | Time lock for the atomic swap |
chain | chain | The blockchain where the atomic swap is executed |
asset | asset | The asset being swapped |
amount | string | The amount to be filled in HTLC |
filledAmount | string | The amount filled in the HTLC |
initiateTxHash | string | Transaction hash of the initiation transaction |
redeemTxHash | string | Transaction hash of the redemption transaction |
refundTxHash | string | Transaction hash of the refund transaction |
priceByOracle | float64 | Price of the token involved (BTC or WBTC) |
minimumConfirmations | uint64 | Minimum number of blockchain conformations required |
currentConfirmations | uint64 | Current number of confirmations |
initiateBlockNumber | uint64 | Block number of the initiation transaction |
Every order involves two parties and two corresponding atomic swaps. The initiator initiates in their own initiator atomic swap and redeems funds from the follower atomic swap. Similarly, the follower initiates in their follower atomic swap and redeems in the initiator atomic swap. Refunds occur within the same atomic swap; for instance, the initiator redeems in their own initiator atomic swap.
- To find the initiate transaction of the initiator, use the initiate transaction hash from the initiator atomic swap.
- To find the redeem transaction of the initiator, use the redeem transaction hash from the follower atomic swap.
- To find the refund transaction of the initiator, use the refund transaction hash from the initiator atomic swap.
Example
{
"ID": 8086,
"CreatedAt": "2024-01-16T00:18:11.350761Z",
"UpdatedAt": "2024-01-18T17:52:27.605397Z",
"DeletedAt": null,
"maker": "0xaf0fdd39e5d92499b0ed9f68693da99c0ec1e92e",
"taker": "0xb9c43f86e153acc31e4ae39fde1f5887e05f8d51",
"orderPair": "bitcoin-ethereum:0xA5E38d098b54C00F10e32E51647086232a9A0afD",
"InitiatorAtomicSwapID": 16171,
"FollowerAtomicSwapID": 16172,
"initiatorAtomicSwap": {
"ID": 16171,
"CreatedAt": "2024-01-16T00:18:11.167048Z",
"UpdatedAt": "2024-01-18T17:52:27.319582Z",
"DeletedAt": null,
"swapStatus": 5,
"secretHash": "",
"secret": "",
"onChainIdentifier": "bc1qptjlcdqjx92rate7aylgm55zvtt84k0ng4z0z0x5pjd29hvmpp6sc5mq7c",
"initiatorAddress": "1PCDCnwG39jnHQ9YRmB1MrCx1wFNMT5qjB",
"redeemerAddress": "bc1q6ladqd8xssdkvp0re7mzyuz5gjtmea4sjlx8sl",
"timelock": "288",
"chain": "bitcoin",
"asset": "primary",
"amount": "55000000",
"filledAmount": "55000000",
"initiateTxHash": "c0926a24c8838c3d2aef8d021138113a3b551fbe98e29a2bc7f6edfe6da44f32",
"redeemTxHash": "",
"refundTxHash": "5407728e50158c04ceff8b79821724ab1f365bb27a95d70d9d3510b68535495f",
"priceByOracle": 43020.05493015489,
"minimumConfirmations": 4,
"currentConfirmation": 4,
"initiateBlockNumber": 825951
},
"followerAtomicSwap": {
"ID": 16172,
"CreatedAt": "2024-01-16T00:18:11.213118Z",
"UpdatedAt": "2024-01-18T17:52:27.176631Z",
"DeletedAt": null,
"swapStatus": 5,
"secretHash": "",
"secret": "",
"onChainIdentifier": "dc609bcc0ac9748cb555f0376a079588e1ee3e6b8aaeb91442ef47666de267e6",
"initiatorAddress": "0xb9C43F86E153acc31e4aE39fDE1f5887e05F8D51",
"redeemerAddress": "0xaf0FDd39e5D92499B0eD9F68693DA99C0ec1e92e",
"timelock": "7200",
"chain": "ethereum",
"asset": "0xA5E38d098b54C00F10e32E51647086232a9A0afD",
"amount": "54835000",
"filledAmount": "",
"initiateTxHash": "0x6c632a407fe8bb000b9305023f3fdd087cf8d7754c06ad98befddcde00711899",
"redeemTxHash": "",
"refundTxHash": "0x88ef6f80cc6ed44c3d759aaeb0ddaa712c7d9a5288f031f04ff38c70dc5fa757",
"priceByOracle": 43020.05493015489,
"minimumConfirmations": 12,
"currentConfirmation": 12,
"initiateBlockNumber": 19016028
},
"secretHash": "fd2497d28fb25d39778f376afbc9d05fe7e2eb6909d589dd74c976f92f2066a6",
"secret": "",
"price": 1.0030090270812437,
"status": 4,
"secretNonce": 15,
"userBtcWalletAddress": "bc1qc8tyqltzmvmmdnrjvhegn9gs58688rhqu6xqp8",
}
AuthTokenโ
This endpoint provides a JWT token that remains valid for 24 hours. To obtain the auth token, you need to send a message along with a signature that signs the message.
Payloadโ
Field | Type | Description |
---|---|---|
message | string | A (SIWE) (Something I Want to Encrypt) message, which includes a random nonce and a statement for validation. |
signature | string | Cryptographic signature of the message field to authenticate the request. |
Responseโ
Field | Type | Description |
---|---|---|
token | string | JWT token |
You can use a random nonce to create a message and sign it. Alternatively, you can obtain a truly random nonce from the endpoint (nonce).
Subscribe to Ordersโ
To receive updates from the Orderbook, you can connect to the websocket endpoint and use the subscription texts provided below. If there are no updates, the server will send a ping message every 60 seconds to keep the connection alive. You can send multiple subscription texts in a single websocket connection to receive updates for various criteria simultaneously.
- The ping message object is
{
"type": "ping",
"msg": "ping"
}
Types of subscribe textsโ
-
Subscribe to updated orders: Initially provides all orders associated with the given address (this address can be either the maker's or taker's in the order object). Subsequent responses will include orders associated with the given address that have updates or are newly created.
- Regex:
^0x[0-9a-fA-F]{40}$
- Example:
subscribe::0x3139C33b7218237Bbd22235C78078731216fD05b
- Regex:
-
Subscribe to pending and updated orders: Initially provides all pending orders associated with the given address (this address can be either the maker's or taker's in the order object). Subsequent responses will include orders associated with the given address that have updates or are newly created.
- Regex:
^0x[0-9a-fA-F]{40}-onlyPending$
- Example:
subscribe::0x3139C33b7218237Bbd22235C78078731216fD05b-onlyPending
- Regex:
-
Subscribe to order updates: This will take an orderId in the subscribe text and only respond/send updates if there is an update in that order.
- Regex:
^[0-9]+$
- Example:
subscribe::20000
- Regex:
-
Subscribe to open orders: This subscription takes a chain name and direction as input and sends all newly created orders in that direction.
- Regex:
^[a-zA-Z_]+(:0x[0-9a-fA-F]{40})?-[a-zA-Z_]+(:0x[0-9a-fA-F]{40})?
- Example:
subscribe::bitcoin-ethereum
- In the above example, clients will receive all orders created in the direction between Bitcoin and Ethereum.
For more information about supported chains, visit supported-chains.
- Regex:
Regex is valid for the text after subscribe::
Response Typesโ
Subscription Type | Response Structure |
---|---|
Updated Orders |
|
Pending and Updated Orders |
|
Order Updates |
|
Open Orders |
|
Error |
|
The orders
in the table above are of type Order.
Fill Orderโ
This API endpoint is used to fill an order. You can get all newly created orders by subscribing to orders and then fill an order using this endpoint.
You must stake 210,000 SEED to be eligible to fill an order.
Payloadโ
Field | Type | Description |
---|---|---|
sendAddress | string | Address from which Filler will deposit funds |
receiveAddress | string | Address where Filler wants to receive funds |
Authentication:
Include an Authorization
header with your request. Learn how to obtain an auth token here.
Assetsโ
The assets endpoint returns a JSON object listing all supported chains along with their associated assets available for trading on Garden. Each key in the JSON represents a blockchain supported by Garden, and the corresponding array lists the specific assets available for trading within that blockchain.
Sample response
{
"bitcoin": [
"primary"
],
"bitcoin_testnet": [
"primary"
],
"ethereum": [
"0xA5E38d098b54C00F10e32E51647086232a9A0afD"
],
"ethereum_arbitrum": [
"0x203DAC25763aE783Ad532A035FfF33d8df9437eE"
],
"ethereum_sepolia": [
"0x130Ff59B75a415d0bcCc2e996acAf27ce70fD5eF"
]
}
Nonceโ
The nonce endpoint provides a randomly generated string of length 16.
Responseโ
Field | Type | Description |
---|---|---|
nonce | string | A random string of length 16. |