Paying in supported tokens

For issue of Verified cash tokens

The following code snippet uses etherjs to send ether to the Verified cash contract address.

const factoryContract = new FactoryContract(investorWallet);

await factoryContract.getTokenCount()
.then(async(resp)=>{
console.log("Number of tokens returned by factory " + resp.response.result[0]);
num = resp.response.result[0];

for (count=0; count<10; count++){
    await factoryContract.getToken(count)
    .then(async(resp)=>{
        console.log("Token address iterated " + resp.response.result[0]);
        token = resp.response.result[0];
        
        await factoryContract.getNameAndType(token)
        .then(async(resp)=>{
            console.log("Token name " + ethers.utils.parseBytes32String(resp.response.result[0]));
            console.log("Token type " + ethers.utils.parseBytes32String(resp.response.result[1]));

            if(ethers.utils.parseBytes32String(resp.response.result[1])=="ViaCash"){
                if(ethers.utils.parseBytes32String(resp.response.result[0])=="VXUSD")
                    VCUSD = token;
                if(ethers.utils.parseBytes32String(resp.response.result[0])=="VXEUR")
                    VCEUR = token;
            }            
        })
    })
}

const cashUSDInvestor = new CashContract(investorWallet, VCUSD);

await investorWallet.sendTransaction({
    to: VCUSD,
    value: ethers.utils.parseEther('0.01')
}).then(async()=>{
    console.log('Sent some ether for issuing cash tokens');
    cashUSDInvestor.notifyCashIssue(async()=>{
        await cashUSDInvestor.balanceOf(investorWallet.address)
        .then(async(balance)=>{
            console.log("VCUSD balance in investor wallet " + investorWallet.address + " is " + balance.response.result[0]);
        })
    })
})

Last updated