https://ethereum.stackexchange.com/questions/145206/query-on-ethers-provider-in-hardhat-ethers
how to use provider while using ethers from hardhat-ethers?? How can i use all methods from here while using ethers from hardhat-ethers??
https://ethereum.stackexchange.com/questions/145206/query-on-ethers-provider-in-hardhat-ethers
how to use provider while using ethers from hardhat-ethers?? How can i use all methods from here while using ethers from hardhat-ethers??
https://ethereum.stackexchange.com/questions/145173/concept-of-multisig
Is this concept of multisig is right?
Users first pay the contract that amount of eth which they wanst to send someone, and then owners will execute the transaction after verifying the user
This is all i know about multisig concept. Please tell me the main concept of multisig.
https://ethereum.stackexchange.com/questions/145160/help-me-to-pass-this-test
I am creating a multisig, my verifiy() looks like:
function verify(
address _customer,
address _to,
uint256 _value,
bytes32 _key,
bytes memory _signature,
uint256 nonce
) public alreadySubmitted returns (address) {
require(submitted[_customer]);
_value = _value * 1 ether;
bytes32 signature = getSignature(_to, _value, _key, nonce);
address recovered = recoverSigner(signature, _signature);
if (recovered == _customer) {
verified[msg.sender] = true;
emit Verified(msg.sender, "is now verified. Congrats!!");
}
return recovered;
}
Where it is returning the recovered
address.
I want to test that this function is working properly, test script is:
it("This function verifying properly", async function(){
const{acc5,acc6,multisig} = await loadFixture(deployMultisigFixture)
const customer = acc6.address
const nonce = 1
const to = acc5.address
const value = ethers.utils.parseEther("1")
const key = "0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656f"
let signature = await multisig.connect(acc6).getSignature(to,value,key,nonce)
signature = ethers.utils.joinSignature(signature)
await multisig.connect(acc6).submit(to,key,{value: value})
const verified = await multisig.connect(acc6).verify(customer,to,value,key,signature,nonce)
console.log(verified)
assert.equal(customer,verified.address,"Not equal!")
})
the problem i am having is returned verified
is an object, not an address. so cant can’t check that this address is actually the customer, so can’t verify.
Extra info:
The submit function is for submitting the transaction to this contract:
function submit(address _to, bytes32 _key) public payable {
require(msg.value > 0);
uint256 _value = msg.value / 10 ** 18;
submitted[msg.sender] = true;
transaction[msg.sender] = Transaction(_to, _value, _key);
emit SubmittedWithValue(msg.sender, "submitted", _value, "ether");
emit TransactionSetFor(
"Transaction is set for",
_value,
"by",
msg.sender,
"for",
_to
);
}
https://ethereum.stackexchange.com/questions/145145/query-on-signature-testing
I am taking nonce as input from users and while testing the signature i am giving the nonce = 1, i want my signatures which is calculated 2 times, first by users, and 2nd by my contract,with same data, will be equal. Testing script is this:
it("provided signature is proper signature", async function(){
const {multisig, acc4,acc5} = await loadFixture(deployMultisigFixture)
const to = acc4.address
const nonce = 1
const value = ethers.utils.parseEther("1")
const key = "0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656f"
let signature = await multisig.connect(acc5).getSignature(to,value,key, nonce)
//signature = ethers.utils.joinSignature(signature)
console.log(signature)
let _signature = await multisig.connect(acc5).getSignature(to,value,key, 1)
// _signature = ethers.utils.joinSignature(_signature)
console.log(_signature)
await multisig.connect(acc5).verify(acc5.address,to,value,key,_signature, nonce)
assert.equal(signature,_signature,"not equal!")
})
but in output i getting this where is showing that both signature has different nonce:
{
hash: '0x47d73eab407779b123373278ba77b4d03a1bb898ca7e4cb724ba238dd8462f00',
type: 2,
accessList: [],
blockHash: '0x4fbaa55c6ab30fe7e993fd480ba372e627ee676f2372648de465bd2dc6c79820',
blockNumber: 16653048,
transactionIndex: 0,
confirmations: 1,
from: '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65',
gasPrice: BigNumber { value: "23007746885" },
maxPriorityFeePerGas: BigNumber { value: "1000000000" },
maxFeePerGas: BigNumber { value: "45015493770" },
gasLimit: BigNumber { value: "29025560" },
to: '0xe14058B1c3def306e2cb37535647A04De03Db092',
value: BigNumber { value: "0" },
nonce: 1,
data: '0x17a2c57a00000000000000000000000090f79bf6eb2c4f870365e785982e1f101e93b9060000000000000000000000000000000000000000000000000de0b6b3a7640000df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656f0000000000000000000000000000000000000000000000000000000000000001',
r: '0x60fed132b9a68a00f26b12dd11953d040eeaee0ce88ef00cc88026df7fa5e20d',
s: '0x7a412fc78631b72385d01eb46cf5254606a33cab2d2342b9f7bedf60007dc7e8',
v: 1,
creates: null,
chainId: 31337,
wait: [Function (anonymous)]
}
{
hash: '0x6de3fddbaa62e11b569263633ab3b6c1f6fb108f8e18c0fda92437d9a7c8774e',
type: 2,
accessList: [],
blockHash: '0x5e31d613a610889ad7fd766fc8caf5d746f247b1663815a2dd2d38db2e03e151',
blockNumber: 16653049,
transactionIndex: 0,
confirmations: 1,
from: '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65',
gasPrice: BigNumber { value: "20262059284" },
maxPriorityFeePerGas: BigNumber { value: "1000000000" },
maxFeePerGas: BigNumber { value: "39524118568" },
gasLimit: BigNumber { value: "29025560" },
to: '0xe14058B1c3def306e2cb37535647A04De03Db092',
value: BigNumber { value: "0" },
nonce: 2,
data: '0x17a2c57a00000000000000000000000090f79bf6eb2c4f870365e785982e1f101e93b9060000000000000000000000000000000000000000000000000de0b6b3a7640000df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656f0000000000000000000000000000000000000000000000000000000000000001',
r: '0x8fc8330f5654b2853ce24091412b4819cc92cf4c90b34569cecbcc8db9be629b',
s: '0x79168372817f3ca8726baad6a9f80e7400ecfad8217514d2c9c586c9c923b529',
v: 1,
creates: null,
chainId: 31337,
wait: [Function (anonymous)]
}
if nonce for both signature is not same then my code will not work. How to get same nonce for both signatures?
My other functions from contract looks like this:
function getTransactionHash(
address _to,
uint256 _value,
bytes32 _key,
uint256 nonce
) internal pure returns (bytes32) {
bytes32 transactionHash = keccak256(
abi.encodePacked(_to, _value, _key, nonce)
);
return transactionHash;
}
function getEthSignedTransactionHash(
bytes32 _hash
) internal pure returns (bytes32) {
return
keccak256(
abi.encodePacked("x19Ethereum Signed Message:n32", _hash)
);
}
}
https://ethereum.stackexchange.com/questions/145090/testing-confusion
I have addOwner()
like this:
function addOwner(address _owner) public onlyOwner {
require(!owners[_owner]);
owners[_owner] = true;
}
I was testing for function can not be called by others except owner.
Test script:
it("function can not be called by others except owner", async function(){
const {multisig, acc5 } = await loadFixture(
deployMultisigFixture
)
const owner = acc5.address
const _owner = await ethers.getSigner(owner)
assert.isNotOk(multisig.connect(_owner).addOwner(), "error")
})
where acc5 was not set as owner at the time of deployment.
here i am getting this error:
AssertionError: error: expected Promise{…} to be falsy
multisig.connect(_owner).addOwner() is falsy, because _owner is not really the owner, so it should pass, is not it??
https://ethereum.stackexchange.com/questions/145061/query-on-connect
Suppose i deployed a contract like this:const test = await ethers.getContractFactory("Test"); await test.deployed(); const [ signer, acc1, acc2 ] = await ethers.provider.listAccounts()
So, we know signer
is connected by default while any function calling from that contract. What if I want to connect acc1
means i want the function will be called by acc1
, will i have to do like this – await test.connect(acc1). function_from_test()
????
If no then how?
And help me to know usage of connect()
, how to use it?????
https://ethereum.stackexchange.com/questions/144900/query-about-testing
While testing do I need to take arbitrary value for any parameter or variable? Suppose there is a function:
function test(unit a, unit b) public {}
and I have to call that function with arbitrary value as parameter? Like this contract_name.test(2,3)
?