Skip to main content

Quickstart

Everything you will need to get up and running in 2 minutes or less!

Installation

# 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

Import libraries

// 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';

Create a Universal Signer

// (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)

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