someone should please save a brother that have spent hours looking for possible error and tell me what i am missing in this contract cause i am getting ECDSA error message.
code can be found in
https://pastebin.com/WNdKSEAs
Apr 28, 2021, 8:02 AM
cant see the issue.. pls paste it directly?
Apr 28, 2021, 8:49 AM
thanks for checking it out doing that now.
the function:
function placeBet(uint betMask, uint modulo, uint commitLastBlock, uint commit, bytes32 r, bytes32 s)
the signing
const commitLastBlock = await web3.eth.getBlockNumber() + 200;
console.log("1. commitLastBlock:", commitLastBlock.toString());
const secretSigner = "0x027C586E235aefcf54D4f428a18923b47421a49E";
const msg = 1;
const packedCommit =
'0x' + lodash.padStart(msg.toString(16), 64, 0);
const docHash = web3.utils.sha3(packedCommit, {
encoding: 'hex',
});
console.log(docHash: ${docHash});
console.log(signing with account: ${accounts[0]});
let sig = await web3.eth.sign(docHash, secretSigner);
console.log(Signature: ${sig});
let R = 0x${sig.slice(0, 64)}
let S = 0x${sig.slice(64, 128)}
let V;
// V = web3.utils.toDecimal(0x${sig.slice(130, 132)}) + 27;
console.log(V: , R: ${R}, S: ${S});
return await bscg.placeBet(
40, 2, commitLastBlock, docHash, sig.r, sig.s,
{
from: accounts[0],
value: web3.utils.toWei('0.3', 'ether'), //send this value
gasLimit: 150000,
gasPrice: ethers.utils.parseUnits('20', 'gwei')
}
);
function placeBet(uint betMask, uint modulo, uint commitLastBlock, uint commit, bytes32 r, bytes32 s)
the signing
const commitLastBlock = await web3.eth.getBlockNumber() + 200;
console.log("1. commitLastBlock:", commitLastBlock.toString());
const secretSigner = "0x027C586E235aefcf54D4f428a18923b47421a49E";
const msg = 1;
const packedCommit =
'0x' + lodash.padStart(msg.toString(16), 64, 0);
const docHash = web3.utils.sha3(packedCommit, {
encoding: 'hex',
});
console.log(docHash: ${docHash});
console.log(signing with account: ${accounts[0]});
let sig = await web3.eth.sign(docHash, secretSigner);
console.log(Signature: ${sig});
let R = 0x${sig.slice(0, 64)}
let S = 0x${sig.slice(64, 128)}
let V;
// V = web3.utils.toDecimal(0x${sig.slice(130, 132)}) + 27;
console.log(V: , R: ${R}, S: ${S});
return await bscg.placeBet(
40, 2, commitLastBlock, docHash, sig.r, sig.s,
{
from: accounts[0],
value: web3.utils.toWei('0.3', 'ether'), //send this value
gasLimit: 150000,
gasPrice: ethers.utils.parseUnits('20', 'gwei')
}
);
Apr 28, 2021, 9:04 AM
Ok so you are generating V, R, S from script.. And then pass it to smart contract.. And that verifies the user wallet.. Yah?
So the smart contract function fails, or you have issue in Client script side?
So the smart contract function fails, or you have issue in Client script side?
Apr 28, 2021, 9:30 AM
yea, the smartcontract confirmation fail with an error:
Fail with error 'ECDSA signature is not valid.'
due to:
require (secretSigner == ecrecover(signatureHash, 27, r, s), "ECDSA signature is not valid.");
Fail with error 'ECDSA signature is not valid.'
due to:
require (secretSigner == ecrecover(signatureHash, 27, r, s), "ECDSA signature is not valid.");
Apr 28, 2021, 9:32 AM
Can you make a view function in SC.. And see what wallet is returning ecrecover?
That will give clue if that sig is ok or not.. Try putting 28 as V as well.. Sometimes it changes from 27 or 28
That will give clue if that sig is ok or not.. Try putting 28 as V as well.. Sometimes it changes from 27 or 28
Apr 28, 2021, 9:34 AM