-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
pi-nexus-smart-contracts/binance-smart-chain/scripts/execute.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { ethers } = require('ethers'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Load contract addresses from file | ||
const contractAddresses = require('../contractAddresses.json'); | ||
|
||
// Set up Binance Smart Chain provider | ||
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/api/v1/ws/bsc/main'); | ||
|
||
// Set up contract instances | ||
const escrowContract = new ethers.Contract(contractAddresses.Escrow, require('../artifacts/contracts/Escrow.sol/Escrow.json').abi, provider); | ||
const lendingContract = new ethers.Contract(contractAddresses.Lending, require('../artifacts/contracts/Lending.sol/Lending.json').abi, provider); | ||
const tokenizedAssetsContract = new ethers.Contract(contractAddresses.TokenizedAssets, require('../artifacts/contracts/TokenizedAssets.sol/TokenizedAssets.json').abi, provider); | ||
|
||
// Set up user wallet | ||
const userWallet = new ethers.Wallet('0x1234567890abcdef', provider); | ||
|
||
// Execute contract functions | ||
async function execute() { | ||
try { | ||
// Create escrow account | ||
const createEscrowAccountTx = await escrowContract.connect(userWallet).createEscrowAccount('0x1234567890abcdef', 100); | ||
console.log(`Create escrow account transaction hash: ${createEscrowAccountTx.hash}`); | ||
|
||
// Deposit into lending pool | ||
const depositTx = await lendingContract.connect(userWallet).deposit(0, { value: ethers.utils.parseEther('1.0') }); | ||
console.log(`Deposit transaction hash: ${depositTx.hash}`); | ||
|
||
// Create tokenized asset | ||
const createTokenizedAssetTx = await tokenizedAssetsContract.connect(userWallet).createTokenizedAsset('https://example.com/asset-uri'); | ||
console.log(`Create tokenized asset transaction hash: ${createTokenizedAssetTx.hash}`); | ||
|
||
// Transfer tokenized asset | ||
const transferTokenizedAssetTx = await tokenizedAssetsContract.connect(userWallet).transferTokenizedAsset(0, '0x1234567890abcdef'); | ||
console.log(`Transfer tokenized asset transaction hash: ${transferTokenizedAssetTx.hash}`); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
execute(); |