Why this call is not workiing ?¿

Hi there

I am testing a smart contract and everything works fine but the second call to the contract (ajjjj) :

try {

await n.value.methods.withdrawToken().send({

from: i.value

}), p.success(\You have successfully unlock $${[Ht.lockedToken.id](https://Ht.lockedToken.id)} Tokens. Thank you!), U()

} catch {

p.error("Signing failed, please try again!")

}

a.value = !1

}, w = (O, N) => !+O || !+N ? 0 : Number.parseFloat(N) * Number.parseFloat(O), x = (O, N) => !+O || !+N ? 0 : Number.parseFloat(N) / Number.parseFloat(O), k = async () => {

var S;

const O = await n.value.methods.totalTokensSoldR().call(),

N = (S = O == null ? void 0 : O.data) != null ? S : 0;

v.value = m.value.tokensForSale - N, v.value < 0 && (v.value = 0)};

What I do not understand is why calls to withdrawToken (smart contrasct’s function) work fine and when I try to get the value of the variable totalTokensSoldR from smart contract is not working…If I switch variable O=10000, then v.value is calculated correctly .Both withdrawToken() and totalTokensSoldR () are in the ABI…

totalTokensSoldR variable can be read from testnet and is declared as public view, please help ! I’m stucked :frowning:

4 Likes

Hi @Gonza_ortega,
I can’t see what’s wrong with the snippet you have provided. There also seems to be many quotes, etc, missing in your copy/paste of the code. Do you have a github repo to share?

Can you say the error or value returned at await n.value.methods.totalTokensSoldR().call()

Warm regards,
Chris | Infura | ConsenSys

4 Likes