✅ gasleft = remain gas, we can setting the using gas by {gas: gasToUse}

bytes8 gateKey = 16hex = uint64

試してみた

Gate3

Example gatekey = 0x1122334455667788

modifier gateThree(bytes8 _gateKey) {
    console.logBytes8(_gateKey);
    console.log("uint32(uint64(_gateKey)) %s", uint32(uint64(_gateKey)) );
    console.log("uint64(_gateKey) %s", uint64(_gateKey));
    console.log("uint16(tx.origin) %s", uint16(tx.origin));
    require(
        uint32(uint64(_gateKey)) == uint16(uint64(_gateKey)),
        "GatekeeperOne: invalid gateThree part one"
    );
    require(
        uint32(uint64(_gateKey)) != uint64(_gateKey),
        "GatekeeperOne: invalid gateThree part two"
    );
    require(
        uint32(uint64(_gateKey)) == uint16(tx.origin),
        "GatekeeperOne: invalid gateThree part three"
    );
    _;
}
// _gateKey = 0x1122334455667788
// uint**32**(uint64(_gateKey)) 0x55667788 = 1432778632
// uint**64**(_gateKey) 0x1122334455667788 = 1234605616436508552
// uint16(tx.origin) 0xD74C = 55116
// tx.orign = 0x48490375809Cf5Af9D635C7860BD7F83f9f2D74c

Goal is setting (bytes8 _gateKey) ⇒ 16hex ⇒ uint64

  1. uint32(key) = uint16(key)
  2. uint32(key) != uint64(key)
  3. uint32(key) = uint16(tx.origin)

First, try to 3

uint16(tx.origin) = D74C, uint32(key) = 0000D74C

Next is 2

uint32(key) = 0000D74C, uint16(key) = D74C