Quickstart
Everything you will need to get up and running in 2 minutes or less!
Installation
- npm
- yarn
# Core SDK
npm install @pushchain/core
# plus whichever helpers you need:
npm install ethers # for EVM
npm install viem # alternative EVM library
npm install @solana/web3.js # for Solana
# Core SDK
yarn add @pushchain/core
# plus whichever helpers you need:
yarn add ethers
yarn add viem
yarn add @solana/web3.js
Import libraries
- Ethers (v6)
- Viem
- Solana (Web3 JS)
// Import Push Chain SDK and Ethers
// You can use other library like veim, etc
// THIS EXAMPLE FOLLOWS ETHERS IMPLEMENTATION
import { PushChain } from '@pushchain/core';
import { ethers } from 'ethers';
// Import Push Chain SDK and Viem
// You can use other library like ethers, etc
// THIS EXAMPLE FOLLOWS VIEM IMPLEMENTATION
import { PushChain } from '@pushchain/core';
import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts'
import { createWalletClient, http } from 'viem'
import { sepolia } from 'viem/chains'
// Import Push Chain SDK and Solana Web3.js
// You can use other library like @solana/kit, etc
// THIS EXAMPLE FOLLOWS SOLANA WEB3JS IMPLEMENTATION
import { PushChain } from '@pushchain/core';
import { Keypair } from '@solana/web3.js';
Create a Universal Signer
- Ethers (v6)
- Viem
- Solana (Web3 JS)
// (Inside an async function or top-level-await context)
// 1. Connect to a provider (e.g., Push Chain RPC URL)
const provider = new ethers.JsonRpcProvider('https://sepolia.gateway.tenderly.co')
// 2. Create a random wallet (or use your own private key)
const wallet = ethers.Wallet.createRandom(provider)
// 3. Convert ethers signer to Universal Signer
// Most popular libraries can pass just the signer to get universal signer
// Or use PushChain.utils.signer.construct to create a custom one
const universalSigner = await PushChain.utils.signer.toUniversal(wallet)
// (Inside an async function or top-level-await context)
// 1. Create a random wallet (or use your own private key)
const account = privateKeyToAccount(generatePrivateKey())
// 2. Initialize signer
const signer = createWalletClient({
transport: http('https://sepolia.gateway.tenderly.co'), // or your preferred RPC URL
chain: sepolia,
account,
})
// 3. Convert signer to Universal Signer
const universalSigner = await PushChain.utils.signer.toUniversal(signer)
// (Inside an async function or top-level-await context)
// 1. Generate or import your Solana keypair
const solKeypair = Keypair.generate();
// 2. Convert the Solana Keypair into a Push Chain universal signer.
// We use the helper `toUniversalFromKeypair`, which internally builds
// the necessary adapter (signTransaction, signMessage).
const universalSigner = await PushChain.utils.signer.toUniversalFromKeypair(solKeypair, {
chain: PushChain.CONSTANTS.CHAIN.SOLANA_DEVNET,
library: PushChain.CONSTANTS.LIBRARY.SOLANA_WEB3JS,
})
Initialize Push Chain SDK
// ONCE UNIVERSAL SIGNER IS CREATED
// ALL CHAIN IMPLEMENTATION BECOMES UNIVERSAL
// (Inside an async function or top-level-await context)
// Initialize Push Chain SDK
const pushChainClient = await PushChain.initialize(universalSigner, {
network: PushChain.CONSTANTS.PUSH_NETWORK.TESTNET,
});
Send Transaction
// ONCE UNIVERSAL SIGNER IS CREATED
// ALL CHAIN IMPLEMENTATION BECOMES UNIVERSAL
// (Inside an async function or top-level-await context)
// Send a universal transaction (from any chain to Push Chain)
const txHash = await pushChainClient.universal.sendTransaction({
to: '0xD0DE00000447492307108Bdc7Ff6BaB33Ff37Dacc479', // To address on Push Chain
value: BigInt(1), // $PC Value to send
});
console.log('Transaction sent:', txHash);
Inspect your Accounts
// ONCE PUSH CHAIN CLIENT IS INITIALIZED
// ALL CHAIN IMPLEMENTATION BECOMES UNIVERSAL
// Get the account that is connected to Push Chain Client
const pushChainAccount = pushChainClient.universal.account;
console.log(
'Account connected to Push Chain Client:',
pushChainAccount.address
);
// Get the account that is connected to Push Chain Client
const originAccount = pushChainClient.universal.origin;
console.log(
'Origin address that is controlling the account connected to Push Chain Client'
);
console.log(
"Origin address is only present if other chain's address is connected to Push Chain Client"
);
console.log('Else it will be the same as pushChainClient.universal.account');
console.log('Origin address:', originAccount.address);
Next Steps
-
Start Building with Core SDK
-
Explore core abstractions in Important Concepts
-
Try a full-app walkthrough in Tutorials
-
For deep dives visit our Knowledge Base