Layerswap Swidge Usage
Select a Layerswap adapter, bind the matching source account and preview an exact-input route.
Community modules are developed and maintained independently by third-party contributors.
Tether and the WDK Team do not endorse or assume responsibility for their code, security, or maintenance. Use your own judgment and proceed at your own risk.
Installation
For Node.js 22, use 22.21.0 or later in the 22.x line; for Node.js 24, use 24.9.0 or later in the 24.x line to satisfy the published dependencies.
Install the adapter for the account that sends the deposit. The commands below pin version 1.0.0 and install the shared core automatically.
The published adapters pin base Wallet 1.0.0-beta.25 and these concrete wallets:
| Adapter | Wallet dependency |
|---|---|
| EVM | @tetherto/wdk-wallet-evm@1.0.0-beta.24 and @tetherto/wdk-wallet-evm-erc-4337@1.0.0-beta.23 |
| Solana | @tetherto/wdk-wallet-solana@1.0.0-beta.20 |
| Bitcoin | @tetherto/wdk-wallet-btc@1.0.0-beta.17 |
| TON | @tetherto/wdk-wallet-ton@1.0.0-beta.17 |
These are dependency pins, not minimum-version promises. The packages expose ESM, TypeScript declarations and a Bare entry. The default HTTP client requires global fetch and AbortController; a Bare entry alone does not configure a native application or its wallet providers.
Bind the matching account
Use the import for your source wallet. Each function accepts an account your application has already initialized and optional protocol configuration.
EVM or ERC-4337
npm install @layerswap/wdk-protocol-swidge-layerswap-evm@1.0.0import LayerswapProtocolEvm from '@layerswap/wdk-protocol-swidge-layerswap-evm'
export function bindEvmAccount(account, config = {}) {
return new LayerswapProtocolEvm(account, config)
}Use an EVM account connected to the intended source network. The EVM adapter also accepts the matching ERC-4337 account.
Solana
npm install @layerswap/wdk-protocol-swidge-layerswap-solana@1.0.0import LayerswapProtocolSolana from '@layerswap/wdk-protocol-swidge-layerswap-solana'
export function bindSolanaAccount(account, config = {}) {
return new LayerswapProtocolSolana(account, config)
}Use a Solana account with its RPC provider. Execution needs the writable transaction interface and the account's public key.
Bitcoin
npm install @layerswap/wdk-protocol-swidge-layerswap-bitcoin@1.0.0import LayerswapProtocolBitcoin from '@layerswap/wdk-protocol-swidge-layerswap-bitcoin'
export function bindBitcoinAccount(account, config = {}) {
return new LayerswapProtocolBitcoin(account, config)
}Use the pinned Bitcoin wallet account. The adapter builds a signed deposit through that wallet's HD-signing and client implementation; an arbitrary address-only account cannot execute it.
TON
npm install @layerswap/wdk-protocol-swidge-layerswap-ton@1.0.0import LayerswapProtocolTon from '@layerswap/wdk-protocol-swidge-layerswap-ton'
export function bindTonAccount(account, config = {}) {
return new LayerswapProtocolTon(account, config)
}Use a TON account connected to TON Center. Jetton deposits also need access to the sender's jetton wallet.
Discover identifiers
export async function discoverLayerswap(protocol, sourceNetwork, destinationNetwork) {
const chains = await protocol.getSupportedChains()
const sourceTokens = await protocol.getSupportedTokens({ fromChain: sourceNetwork })
const destinationTokens = await protocol.getSupportedTokens({ toChain: destinationNetwork })
return { chains, sourceTokens, destinationTokens }
}Use a returned chain's id, which is the provider network name, for execution's fromChain and toChain. Use a selected token's token field. Pair it with chain and decimals; its optional address is metadata and is not a universal substitute for the accepted token identifier.
getSupportedTokens() scopes to toChain when present, otherwise fromChain. It ignores fromToken and does not test a route pair. A returned destination can belong to another account family; that does not make it a valid source for the adapter you chose.
Preview an exact-input route
The function accepts selected provider identifiers and a positive amount in source-token base units. Supplying a bigint avoids precision loss from large JavaScript numbers.
export async function previewLayerswap({
protocol,
sourceNetwork,
destinationNetwork,
sourceToken,
destinationToken,
amount
}) {
if (typeof amount !== 'bigint' || amount <= 0n) {
throw new RangeError('Supply a positive bigint amount in source-token base units')
}
return protocol.quoteSwidge({
fromChain: sourceNetwork,
toChain: destinationNetwork,
fromToken: sourceToken,
toToken: destinationToken,
fromTokenAmount: amount,
slippage: 0.005
})
}slippage: 0.005 means 0.5%. Quote discovery can also run without a bound account when fromChain is supplied. It does not create a provider swap or sign a deposit. It also does not validate a destination recipient, refund address or minimum output; those are application and execution concerns. Source gas can be absent when estimation is unavailable or fails, so the fee list is not a guaranteed complete total cost.
Before execution, collect the intended destination recipient, a source-chain refund address and your application-selected output and fee limits. The execution guide keeps these inputs stable while the user reviews them.
Next Steps
Configuration
Set the API endpoint, timeouts and fee controls.
Execute a Swidge
Confirm a source deposit and preserve its identifiers.
Track Settlement
Follow a payout or refund after source submission.