Skip to main content

3. Getting the signer objects

3.1 Example of getting the signer object (for manual EVM testing in the BE):

Avoid using 3.1 setup in production. Use it for initial or backend testing only.


Add your private key to the environment:

touch .env
echo "SK=<Replace this with your Private Key>" >> .env
// EVM chains compatible wallet:
import { Wallet } from "ethers";
import { config } from 'dotenv';
config();
// EVM signer for testing in the BE
const signer = new Wallet(
process.env.SK!,
// Replace 'polygonParams'
// with the relevant parameter
// from the table below
CONFIG.polygonParams?.provider
);
ChainParametersChain Nonce
ElrondelrondParams2
BSCbscParams4
EthereumropstenParams5
AvalancheavalancheParams6
PolygonpolygonParams7
FantomfantomParams8
TrontronParams9
HarmonyharmonyParams12
xDaixDaiParams14
AlgorandalgorandParams15
FusefuseParams16
TezostezosParams18
VelasvelasParams19
AuroraauroraParams21
GodwokengodwokenParams22
GatechaingatechainParams23
VeChainvechainParams25

3.2 Example of getting the signer object (in the FE for web3):

// EVM chains compatible signer:
import ethers from "ethers";
const signer = new ethers.providers.Web3Provider(window.ethereum).getSigner();

3.3 Example of getting the signer object (in the FE for Elrond):

// ELROND provider:
import { ExtensionProvider } from "@elrondnetwork/erdjs/out";
const elrondSigner = ExtensionProvider.getInstance();

3.4 Example of getting the signer object (in the FE for Tron):

// Address is fetched from tronweb
(async () => {
const addresses = await window.tronLink.tronWeb.request({
method: "tron_requestAccounts",
});
const tronSigner = addresses[0];
})();

3.5 Example of getting the signer object (in the FE for Algorand):

import { typedAlgoSigner } from "xp.network/dist/helpers/algorand";
// Use the typedAlgoSigner function to get access to the Algorand signer
const algorandSigner = typedAlgoSigner();

3.6 Example of getting the signer object (in the FE for Tezos):

import { TempleWallet } from "@temple-wallet/dapp";
(async () => {
try {
const available = await TempleWallet.isAvailable();
if (!available) {
throw new Error("Temple Wallet is not installed");
}
const tezosSigner = new TempleWallet("bridge.xp.network");
} catch (error) {
console.error("Error:", error);
}
})();

For the ways of connecting the wallets in the FE check-out our bridge repository