The Shogun SDK React is a TypeScript library that enables cross-chain swaps and transfers between EVM chains and Solana. It provides quote fetching, transaction execution, and fee management capabilities.
npm install @0xshogun/sdk-react
or
yarn add @0xshogun/sdk-react
- Cross-chain token swaps between EVM chains and Solana
- Quote fetching for optimal swap rates
- Transaction execution management
- Fee estimation and management
- Balance tracking across chains
- React hooks and context providers for seamless integration
- Node.js 16 or higher
- TypeScript 4.5 or higher
import { useShogunQuote } from '@0xshogun/sdk';
...
function SwapComponent() {
const { quote, isLoading, error } = useShogunQuote({
fromChain: 'ethereum',
toChain: 'solana',
fromToken: '0x...',
toToken: '...',
amount: '1000000000000000000'
});
}
'use client';
import { useSwap } from '@/store';
import { ShogunBalancesProvider, ShogunQuoteProvider, Token } from '@0xshogun/sdk';
import { useMemo } from 'react';
export const ShogunProvider = ({ children }: { children: React.ReactNode }) => {
const {
inputAmount,
tokenIn,
tokenOut,
recipientAddress,
slippage,
setLatestSuggestedAutoSlippageValue,
setInputAmount,
dynamicSlippage // true/false, only for Solana transactions
} = useSwap(); // Your swaps store
const yourAddresses = {....} // Here your wallet addresses
const affiliateWallets = useMemo(() => {
return {
solana: process.env.NEXT_PUBLIC_SOLANA_AFFILIATE_WALLET!, // Your affiliate wallet on solana
evm: process.env.NEXT_PUBLIC_EVM_AFFILIATE_WALLET!, // Your affiliate wallet on evm chains
};
}, []);
const api = useMemo(() => {
return {
key: process.env.NEXT_PUBLIC_DEXTRA_X_API_KEY!, // Dextra API keys
url: process.env.NEXT_PUBLIC_DEXTRA_URL!, // Dextra API URL
};
}, []);
return (
<ShogunBalancesProvider apiKey={process.env.NEXT_PUBLIC_CODEX_API!}>
<ShogunQuoteProvider
swap={{
tokenIn: tokenIn as Token,
tokenOut: tokenOut as Token,
setLatestSuggestedAutoSlippageValue,
inputAmount,
setInputAmount,
recipientAddress,
slippage,
}}
system={{
api,
systemFeePercent: 0.01,
userEVMAddress: yourAddresses?.turnKeyEVMAddress as string,
userSolanaAddress: yourAddresses?.turnkeySolanaAddress as string,
affiliateWallets,
}}
>
{children}
</ShogunQuoteProvider>
</ShogunBalancesProvider>
);
};
Development
npm install
npm run build
npm test
npm run format
npm run lint
Contributing Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.