Paying in ether and other supported ERC20 tokens
For issue of Verified cash tokens
The following code snippet uses etherjs to send ether to the Verified cash contract address.
1
const factoryContract = new FactoryContract(investorWallet);
2
3
await factoryContract.getTokenCount()
4
.then(async(resp)=>{
5
console.log("Number of tokens returned by factory " + resp.response.result[0]);
6
num = resp.response.result[0];
7
8
for (count=0; count<10; count++){
9
await factoryContract.getToken(count)
10
.then(async(resp)=>{
11
console.log("Token address iterated " + resp.response.result[0]);
12
token = resp.response.result[0];
13
14
await factoryContract.getNameAndType(token)
15
.then(async(resp)=>{
16
console.log("Token name " + ethers.utils.parseBytes32String(resp.response.result[0]));
17
console.log("Token type " + ethers.utils.parseBytes32String(resp.response.result[1]));
18
19
if(ethers.utils.parseBytes32String(resp.response.result[1])=="ViaCash"){
20
if(ethers.utils.parseBytes32String(resp.response.result[0])=="VXUSD")
21
VCUSD = token;
22
if(ethers.utils.parseBytes32String(resp.response.result[0])=="VXEUR")
23
VCEUR = token;
24
}
25
})
26
})
27
}
28
29
const cashUSDInvestor = new CashContract(investorWallet, VCUSD);
30
31
await investorWallet.sendTransaction({
32
to: VCUSD,
33
value: ethers.utils.parseEther('0.01')
34
}).then(async()=>{
35
console.log('Sent some ether for issuing cash tokens');
36
cashUSDInvestor.notifyCashIssue(async()=>{
37
await cashUSDInvestor.balanceOf(investorWallet.address)
38
.then(async(balance)=>{
39
console.log("VCUSD balance in investor wallet " + investorWallet.address + " is " + balance.response.result[0]);
40
})
41
})
42
})
Copied!
Copy link