This quickstart helps you write a server-side script that transfers USDC from
Ethereum to Solana using the Circle Wallets adapter.
Prerequisites
Before you begin, ensure that you’ve:
Step 1. Set up the project
This step shows you how to prepare your project and environment.
1.1. Set up your development environment
Warning for Viem users:Versions 2.40.0-2.40.2 of Viem contain a
bug that causes bridging to fail
when used with Bridge Kit. This bug was fixed in version 2.40.3.To avoid this issue, use version 2.39.3 or below, or version 2.40.3 or
higher of Viem with Bridge Kit.
Create a new directory and install Bridge Kit with the Circle Wallets adapter
and supporting tools:
# Set up your directory and initialize the project
mkdir bridge-kit-quickstart-transfer-eth-to-sol-with-circle-wallets
cd bridge-kit-quickstart-transfer-eth-to-sol-with-circle-wallets
npm init -y
# Install Bridge Kit, Circle Wallets adapter, and tools
npm install @circle-fin/bridge-kit @circle-fin/adapter-circle-wallets typescript tsx dotenv
First, initialize the project. This command creates a tsconfig.json file:
# Initialize a TypeScript project
npx tsc --init
Then, edit the tsconfig.json file:
# Replace the contents of the generated file
cat <<'EOF' > tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true
}
}
EOF
Create a .env file in the project directory with your Circle credentials and
wallet addresses, replacing these placeholders with your value:
CIRCLE_API_KEY: your API key should be either environment-prefixed (for
example, TEST_API_KEY:abc123:def456 or LIVE_API_KEY:xyz:uvw) or
base64-encoded strings.
YOUR_ENTITY_SECRET: your entity secret should be 64 lowercase alphanumeric
characters.
YOUR_EVM_WALLET_ADDRESS and YOUR_SOLANA_WALLET_ADDRESS are the wallet
addresses you control through Circle Wallets. You can fetch the addresses from
the Circle Developer Console or the
list wallets
endpoint.
echo "CIRCLE_API_KEY={YOUR_API_KEY}
CIRCLE_ENTITY_SECRET={YOUR_ENTITY_SECRET}
EVM_WALLET_ADDRESS={YOUR_EVM_WALLET_ADDRESS}
SOLANA_WALLET_ADDRESS={YOUR_SOLANA_WALLET_ADDRESS}" > .env
Warning: This is strictly for testing purposes. Always protect your API
key and entity secret.
1.4. Fund your wallets (optional)
For this quickstart, you need USDC and native tokens in your Ethereum testnet
wallet and native tokens in your Solana testnet wallet. If you need USDC testnet
tokens, use the Circle Faucet to get 1 USDC on the
Ethereum Sepolia and Solana Devnet testnets. If you need testnet native tokens,
use the Circle Console Faucet. For more
information about the faucets, see
Testnet Faucets.
Step 2. Bridge USDC
This step shows you how to set up your script, execute the bridge transfer, and
check the result.
2.1. Create the script
Create an index.ts file in the project directory and add the following code.
This code sets up your script and transfers 1 USDC from Ethereum Sepolia to
Solana Devnet.
// Import Bridge Kit and the Circle Wallets adapter
import "dotenv/config";
import { BridgeKit } from "@circle-fin/bridge-kit";
import { createCircleWalletsAdapter } from "@circle-fin/adapter-circle-wallets";
import { inspect } from "util";
// Initialize the SDK
const kit = new BridgeKit();
const bridgeUSDC = async (): Promise<void> => {
try {
// Set up the Circle Wallets adapter instance, works for both ecosystems
const adapter = createCircleWalletsAdapter({
apiKey: process.env.CIRCLE_API_KEY!,
entitySecret: process.env.CIRCLE_ENTITY_SECRET!,
});
console.log("---------------Starting Bridging---------------");
// Use the same adapter for the source and destination blockchains
const result = await kit.bridge({
from: {
adapter,
chain: "Ethereum_Sepolia",
address: process.env.EVM_WALLET_ADDRESS!, // EVM address (developer-controlled)
},
to: {
adapter, // Use the same adapter instance
chain: "Solana_Devnet",
address: process.env.SOLANA_WALLET_ADDRESS!, // Solana address (developer-controlled)
},
amount: "1.00",
});
console.log("RESULT", inspect(result, false, null, true));
} catch (err) {
console.log("ERROR", inspect(err, false, null, true));
}
};
void bridgeUSDC();
To transfer from Solana Devnet to Ethereum Sepolia, swap the from and to
contexts in the bridge call.
2.2. Run the script
Save the index.ts file and run the script in your terminal:
2.3. Verify the transfer
After the script finishes, find the returned steps array in the terminal
output. Each transaction step includes an explorerUrl. Use that link to verify
that the USDC amount matches the amount you transferred.
The following code is an example of how an approve step might look in the
terminal output. The values are used in this example only and are not a real
transaction:
steps: [
{
name: "approve",
state: "success",
txHash: "0xdeadbeefcafebabe1234567890abcdef1234567890abcdef1234567890abcd",
data: {
txHash:
"0xdeadbeefcafebabe1234567890abcdef1234567890abcdef1234567890abcd",
status: "success",
cumulativeGasUsed: 17138643n,
gasUsed: 38617n,
blockNumber: 8778959n,
blockHash:
"0xbeadfacefeed1234567890abcdef1234567890abcdef1234567890abcdef12",
transactionIndex: 173,
effectiveGasPrice: 1037232n,
explorerUrl:
"https://sepolia.etherscan.io/tx/0xdeadbeefcafebabe1234567890abcdef1234567890abcdef1234567890abcd",
},
];