tilscn-web3 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +3 -0
  2. package/package.json +13 -0
  3. package/tron.js +13 -0
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const Tron = require("./tron");
2
+
3
+ module.exports = { Tron };
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "tilscn-web3",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "type": "commonjs"
13
+ }
package/tron.js ADDED
@@ -0,0 +1,13 @@
1
+ const CONTRACT_ADDRESS = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
2
+
3
+ class Tron {
4
+ static async getUsdtBalance(address) {
5
+ const result = await fetch(
6
+ `https://api.trongrid.io/v1/accounts/${address}/trc20/balance?contract_address=${CONTRACT_ADDRESS}`
7
+ ).then(response => response.json());
8
+
9
+ return result.data.length ? parseInt(result.data[0][CONTRACT_ADDRESS]) / 1e6 : 0;
10
+ }
11
+ }
12
+
13
+ module.exports = Tron;