CRYPTO NEWS

Why sender is allowed to set gas price?

On Ethereum transactions, I read that for every transaction, a sender sets a gas limit and gas price. The product of gas price and gas limit represents the maximum amount of Wei that the sender is willing to pay for executing a transaction.

It’s logical for a sender to have a say on gas limit as sender owns the transaction, but how can a sender also decide gas price. Shouldn’t it be something at system level? Otherwise, every sender would like to keep it at minimum.

How do I properly sign and utilize a signature to do a transaction

I know how to create signatures for accounts using web3.eth.sign(). However, My process could be wrong so please correct me. web3.eth.sign(accounts[0].address, text="test") I then have to use the account and the signature to carry out this function function mintTokensWithSignature( uint256 amount, bytes32 _r, bytes32 _s, uint8 _v ) public { bytes memory prefix = "x19Ethereum::Listen

I know how to create signatures for accounts using web3.eth.sign(). However, My process could be wrong so please correct me.

   web3.eth.sign(accounts[0].address, text="test") 

I then have to use the account and the signature to carry out this function

 function mintTokensWithSignature(         uint256 amount,         bytes32 _r,         bytes32 _s,         uint8 _v     ) public {         bytes memory prefix = "x19Ethereum Signed Message:n32";         bytes32 messageHash = keccak256(             abi.encode(address(this), amount, msg.sender)         );         bytes32 hashToCheck = keccak256(abi.encodePacked(prefix, messageHash));         require(             signer == ecrecover(hashToCheck, _v, _r, _s),             "Wrong signature"         );         _mint(msg.sender, amount);     } 

I know I have to recover the _r, _s, _v values which is where I struggle. Since it uses ecrecover v needs to be either 27 or 28, but no matter how I split the signatures or try, I always get "Wrong Signature". Any help would be greatly appreciated!

Why sender is allowed to set gas price?

Shopping cart
There are no products in the cart!
Continue shopping
0