Getting Started

Prerequisite: You should have installed Node.js (version 18.10.0 or higher).

Install the npm package to get started with the Bastion SDK.

In your terminal
npm install --save bastion-wallet-sdk

OR

yarn add bastion-wallet-sdk

Step 0 - Create an API key

First, go to the Bastion Dashboard and create an API key.

We DO NOT charge for testnet transactions. For Mainnet transactions, if you want the gas to be sponsored by a Paymaster, then you need to top up your account on the Bastion dashboard and make sure that you have enough balance there for all the transactions to go through.

Step 1 - Import the Bastion SDK into your app

import { Bastion } from "bastion-wallet-sdk"

Step 2 - Instantiate the Bastion SDK with an ether.js web3 provider

const bastion = new Bastion();
const bastionConnect = await bastion.bastionConnect;

const CONFIG = {
	chainId: <chain_id>, // optional
	privateKey: <your_private_key>, //optional
	rpcUrl: <RPC_URL>, //optional
	apiKey: <your_api_key> //required
};			
await bastionConnect.init(<your_web3Provider>, CONFIG);

In the above code, replace the Config variables as required.

All the Config fields EXCEPT apiKey are optional. You can leave them empty if you pass a web3 provider with a signer (such as when using Metamask, Particle Auth, or web3 auth).

Note:- If you're using the SDK in a NodeJS backend environment and are not passing a web3Provider, then you NEED to pass a Private Key in the CONFIG.

You can find more info about creating the web3 provider and the various configurations in the Tutorials section.

Last updated