Skip to content

Commit

Permalink
Create client.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 11, 2024
1 parent 2ec09c8 commit 2dd5297
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions blockchain_integration/pi_network/pi-stablecoin/client/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// client.js
const Web3 = require('web3');
const axios = require('axios');

class PiStableCoinClient {
constructor() {
this.web3 = new Web3(new Web3.providers.HttpProvider('https://pi-network-node.com'));
this.contractAddress = '0x...'; // Pi Stable Coin contract address
}

async getBalance(address) {
// Get the balance of a user
const balance = await this.web3.eth.Contract(this.contractAddress, 'balanceOf', address);
return balance;
}

async transfer(from, to, amount) {
// Transfer PSI tokens from one user to another
const tx = await this.web3.eth.Contract(this.contractAddress, 'transfer', from, to, amount);
return tx;
}

async stabilize() {
// Call the stabilize function on the Pi Stable Coin contract
const tx = await this.web3.eth.Contract(this.contractAddress, 'stabilize');
return tx;
}
}

module.exports = PiStableCoinClient;

0 comments on commit 2dd5297

Please sign in to comment.