How can I generate the v,r,s in Python given the contents of the smart contract

187 views Asked by At

So I'm trying to send a transaction with python that use the function collectFromTiles in this smart contract: https://polygonscan.com/address/0x068adc06faff086ee9ef826c0b83e7710e223c3d#code This is the function's code from polygonscan:

function collectFromTiles(CollectOrder[] memory _orders,
        uint8 _v,
        bytes32 _r,
        bytes32 _s) checkSignature(_v, _r, _s) external override {
        uint arrayLen = _orders.length;
        uint[] memory ids = new uint[](arrayLen);
        uint[] memory amounts = new uint[](arrayLen);
        uint cId;
        uint cAmount;
        // I hate this loop
        for (uint i; i < _orders.length; i++) {
            (cAmount, cId) = _handle_collect(_orders[i].x, _orders[i].y, _orders[i].z);
            ids[i] = cId;
            amounts[i] = cAmount;
        }
        // Reusing cId, cAmount to save on variables here
        mint.trustedBatchMint(msg.sender, ids, amounts);
    }

Next is the function to get the v,r,s:

modifier checkSignature(uint8 _v,
        bytes32 _r,
        bytes32 _s){
        if (enableSignature) {
            address signer = ECDSA.recover(_hashTypedDataV4(keccak256(
                    abi.encode(COLLECT_MESSAGE, msg.sender, nonces[msg.sender]++)
                )), _v, _r, _s);
            require(signers[signer], "MISSION_CONTROL: INVALID_SIGNATURE");
        }
        _;
    }

and finally is the COLLECT_MESSAGE:

bytes32 private constant COLLECT_MESSAGE = keccak256("CollectMessage(address _user,uint256 _nonce)");

I'm looking for an outline of how I can extract the v,r,s using web3.py

1

There are 1 answers

0
Dion On

I think he wants to do a transaction like this https://polygonscan.com/tx/0x0a37f5af0aa5b15431e339a7dc4ce3bdc77f229e8bd69025a4740812e0c55e6f

where the collectFromTiles function is called

the ABI contract is not in this contract. it's in the contract https://polygonscan.com/address/0x068adc06faff086ee9ef826c0b83e7710e223c3d#writeContract

I think he wants to know. how to get all parameters to call this method.

I'm using python web3

enter image description here

enter image description here