31 lines
944 B
TypeScript
31 lines
944 B
TypeScript
|
import { formatUnits, Contract, Address, ABI, BigNumber } from "ethers";
|
||
|
import { ethers} from "./node_modules/ethers/dist/ethers.min.js";
|
||
|
|
||
|
export async function getDECACCDBAddress(providerURL: string): Promise<string> {
|
||
|
const provider = new ethers.JsonRpcProvider(providerURL);
|
||
|
let contract_address: Address = "0x3556A5005D5411603e0115efD9B875FdFb3ad7E9";
|
||
|
let abi: ABI = [
|
||
|
"function symbol() view returns (string)",
|
||
|
"function decimals() view returns (uint)",
|
||
|
"function _CCDBAddress() view returns (string)"
|
||
|
];
|
||
|
|
||
|
// Create a contract
|
||
|
let contract: Contract = new Contract(contract_address, abi, provider);
|
||
|
|
||
|
try {
|
||
|
let ccdbadd: string = await contract._CCDBAddress();
|
||
|
return ccdbadd;
|
||
|
} catch (error) {
|
||
|
console.error('Error fetching CCDBAddress:', error);
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//async function main() {
|
||
|
// let ccdbadd: string = await getDECACCDBAddress();
|
||
|
// console.log(ccdbadd);
|
||
|
//}
|
||
|
//
|
||
|
//main();
|