gasyard-sdk
v1.0.10
Published
SDK for Gasyard.fi bridge API interactions
Maintainers
Readme
Gasyard SDK
A Node.js SDK for interacting with the Gasyard API, supporting cross-chain quotes, bridging, status, history, and balance queries.
Installation
npm install gasyard-sdkUsage
const { GasyardSDK } = require('gasyard-sdk');
const sdk = new GasyardSDK({
apiKey: 'YOUR_API_KEY',
// baseUrl: 'https://api.gasyard.fi/api/sdk', // optional, defaults to mainnet
// timeout: 10000 // optional
});Methods
getConfig
Retrieve configuration details for all supported networks.
const networks = await sdk.getConfig();- Returns:
ConfigResponse[] - Fields:
networkName,networkChainID,chainID,baseToken,decimals,gatewayContract,solverContract,logoURL,supportedAddress
getQuote
Fetch a quote for token swaps between networks.
const quote = await sdk.getQuote({
inputTokenContract: '...',
inputNetwork: 1,
outputNetwork: 2,
inputTokenAmount: '1000000',
outputTokenContract: '...'
});- Returns:
QuoteResponse - Note: Use valid network/token pairs from
getConfig.
getStatus
Check the status of a transaction.
const status = await sdk.getStatus({ sourceHash: '0x...' });- Returns:
StatusResponse[] - Fields include:
inputTxHash,outputTxHash,managerHash?,outputChainAmount?,collateral?,status,solver?,refundHash?,unlockHash?,fillTime?,inputChainID,outputChainID,inputToken?,outputToken?,inputChainAmount?,inputAddress?,outputAddress?,orderID?,createdAt?,updatedAt?,id?- Fields marked
?are optional or may be null.
getHistory
Fetch transaction history for a wallet address.
const history = await sdk.getHistory({ inputAddress: '0x...' });- Returns:
HistoryResponse resultsarray fields:inputTxHash,outputTxHash,managerHash,outputChainAmount,fees,collateral,status,solver,refundHash?,unlockHash?,fillTime?,_id?,inputChainID,outputChainID,inputToken,outputToken,inputChainAmount,inputAddress,outputAddress,orderID,createdAt,updatedAt,filledAt- Fields marked
?are optional or may be null.
bridge
Initiate a token bridging transaction.
const bridgeTx = await sdk.bridge({
sourceNetwork: 1,
destinationNetwork: 2,
tokenOutAddress: '...',
destinationAddress: '0x...',
tokenInAddress: '...',
sourceTokenAmount: '1000000'
});- Returns:
BridgeResponse
getBalance
Get the token balances for a user address (EVM or Solana).
const balance = await sdk.getBalance({ userAddress: '0x...' });- Returns:
BalanceResponse - Fields:
walletAssets.totalBalanceUsd,walletAssets.assets[](see below)- Asset fields (EVM):
blockchain,tokenName,tokenSymbol,tokenDecimals,tokenType,contractAddress,holderAddress?,balance,balanceRawInteger?,balanceUsd,tokenPrice?,thumbnail? - Asset fields (Solana):
blockchain,tokenName,tokenSymbol,tokenDecimals,tokenType,contractAddress,balance,balanceUsd
Keeping SDK Interfaces in Sync
- The SDK interfaces are regularly validated against the live API using the included
test-sdk.jsscript. - To run all tests and see the actual API responses compared to the SDK types:
node test-sdk.js- This will print the structure of all responses and highlight any mismatches.
Error Handling
- All methods throw
GasyardSDKErroron error, with a clear message and status code if available.
License
MIT
