import { KeyPair } from "@near-js/crypto"; import { JsonRpcProvider } from "@near-js/providers"; import { Account } from "@near-js/accounts"; import { KeyPairSigner } from "@near-js/signers"; const PRIVATE_KEY = process.env.INTERACT_PRIVATE_KEY! as `ed25519:${string}`; const WALLET_ID = process.env.INTERACT_ACCOUNT_ID!; const keyPair = KeyPair.fromString(PRIVATE_KEY); const signer = new KeyPairSigner(keyPair); const provider = new JsonRpcProvider({ url: "https://free.rpc.fastnear.com", }); const account = new Account(WALLET_ID, provider, signer); const BRIDGE_API_URL = "https://bridge.chaindefuser.com/rpc"; export const playgroundHelper = { account, vaultContractId: process.env.VAULT_CONTRACT_ID!, vaultPublicKey: keyPair.getPublicKey(), provider, }; export async function getBridgeDepositAddress(): Promise { const BRIDGE_API_URL = "https://bridge.chaindefuser.com/rpc"; const request = { id: 1, jsonrpc: "2.0", method: "deposit_address", params: [ { account_id: playgroundHelper.vaultContractId, chain: "eth:42161", }, ], }; const response = await fetch(BRIDGE_API_URL, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(request), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data); /* { id: 1, jsonrpc: "2.0", result: { address: "0xB25c324c95652Cff239a0D13dB03080af618263A", chain: "eth:42161", }, }*/ return data; } getBridgeDepositAddress();