This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function method1(payload) { | |
return Buffer.from(payload, 'base64').toString('utf-8'); | |
} | |
async function method2(payload) { | |
const uint8_array = await ethers.utils.base64.decode(payload); | |
const char_array = Array.from(uint8_array).map((element) => { | |
return String.fromCharCode(element) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.13; | |
contract Victim { | |
mapping(address => uint256) public balances; | |
function deposit() public payable { | |
balances[msg.sender] += msg.value; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.13; | |
contract A { | |
uint256 public x; | |
function foo() public payable { | |
x++; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.1; | |
contract A { | |
function method() public pure virtual returns (string memory) { | |
return "A"; | |
} | |
} | |
contract B is A { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main function | |
async function main() { | |
// Declare Signer object | |
const HRE_EOAs = await hre.ethers.getSigners(); | |
// Deploy contracts | |
const factory_seq = await hre.ethers.getContractFactory("SortedSequence", HRE_EOAs[0]); | |
const contract_seq = await factory_seq.deploy(); | |
await contract_seq.deployed(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.1; | |
contract SortedSequence { | |
uint256[100] public _array; | |
mapping(uint256 => bool) public _mapping; | |
function setValue(uint256[100] calldata init_seq) public { | |
for(uint8 i = 0; i < 100; i++) { | |
_array[i] = init_seq[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Constants | |
const EXIT_SUCCESS = 0; | |
const EXIT_FAILURE = 1; | |
// Method1: Query getCanvasSlice() 36 times, sequential | |
async function method1(contract) { | |
for(let i = 0; i < 36; i++) { | |
var args = [(i).toString(), (i+1).toString()]; | |
await contract.getCanvasSlice(...args); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.1; | |
// The compiler does not reserve a storage slot for these variables. | |
uint256 constant dim1 = 36; | |
uint256 constant dim2 = 36; | |
uint256 constant dim = dim1 * dim2; | |
// Use the original "struct Cell" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.8.1 <0.9.0; | |
/** | |
* @dev | |
* The original contract: | |
* https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#code | |
*/ | |
interface IWeth9 { | |
function allowance(address, address) external returns (uint256); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.8.0 <0.9.0; | |
contract D1 { | |
function A() public pure { // 21437, MAX | |
uint256 x; | |
x+=1; | |
} | |
function B() public pure { // 21333, min | |
uint256 x; |