Skip to content

Instantly share code, notes, and snippets.

View Aboudjem's full-sized avatar

Adam Boudj Aboudjem

View GitHub Profile
pragma solidity ^0.6.0;
import "openzeppelin-solidity/contracts/access/Roles.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
contract AgentRole is Ownable {
using Roles for Roles.Role;
event AgentAdded(address indexed account);
event AgentRemoved(address indexed account);
@Aboudjem
Aboudjem / dump.json
Created November 2, 2021 08:24
dumpAll
This file has been truncated, but you can view the full file.
[{"model": "callback.sendqueue", "pk": 1, "fields": {"contract": "PricingTable", "method": "addPricingTableItem", "params": [[5000000, 10000000, 1, 20, 29, 80000, 90000, 6500, 7000, 1200, 1600, true]], "sent": true, "success": true, "txid": "0x8595dc92d4c1d3be45ac122f49b1d9b5d1e0e862c605a2de623d1734f3f53a02", "db_object_id": 1, "returned": 606, "created": "2021-09-27T18:15:35.026", "updated": "2021-09-27T18:15:40.641"}}, {"model": "callback.sendqueue", "pk": 2, "fields": {"contract": "PricingTable", "method": "addPricingTableItem", "params": [[5000000, 10000000, 3, 20, 29, 80000, 90000, 7000, 7500, 1200, 1600, true]], "sent": true, "success": true, "txid": "0x3a6b6d598ddabbf8715b3bfe2c773033d5f8d7b447ceb871e7ce07244f5777f6", "db_object_id": 2, "returned": 607, "created": "2021-09-27T18:15:42.728", "updated": "2021-09-27T18:15:46.690"}}, {"model": "callback.sendqueue", "pk": 3, "fields": {"contract": "PricingTable", "method": "addPricingTableItem", "params": [[5000000, 10000000, 5, 20, 29, 70000, 90000, 7500,
@Aboudjem
Aboudjem / Token.sol
Created November 29, 2021 10:43
ERC20 Token
// Sources flattened with hardhat v2.7.0 https://hardhat.org
// File @openzeppelin/contracts/utils/Context.sol@v4.4.0
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
@Aboudjem
Aboudjem / FatherSonContract.sol
Created March 8, 2022 16:33
FatherSonContract
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.12;
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/IERC20.sol";
contract TestContract {
address mySonAddress;
uint amountToSend;
uint expirationDate;
@Aboudjem
Aboudjem / TestContract.sol
Created March 8, 2022 19:14
TestContract
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.12;
contract TestContract {
uint public myUint = 111222333444555;
string private myString;
address public myAddress;
constructor(string memory _newString) {
/**
*Submitted for verification at Etherscan.io on 2021-10-19
*/
// SPDX-License-Identifier: MIT
// File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.3.2
pragma solidity ^0.8.0;
@Aboudjem
Aboudjem / testKeccak.sol
Created March 16, 2022 15:31
Test Keccak256 with string and bytes32
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.12;
contract Test {
function getBytes32() external pure returns (bytes32, bytes32) {
bytes32 withString = keccak256(abi.encode("0x0000000000000000000000000000000000000000000000000000000000000001"));
bytes32 withBytes32 = keccak256(abi.encode(0x0000000000000000000000000000000000000000000000000000000000000001));
return (withString, withBytes32);
}
}
@Aboudjem
Aboudjem / TestERC1155.sol
Created March 16, 2022 22:06
Test ERC1155
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/ERC1155.sol";
contract TestERC1155 is ERC1155 {
constructor() ERC1155 ("test") {
// SPDX-License-Identifier: GPL-2.0-or-later
// File @uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolImmutables.sol@v1.0.0
pragma solidity >=0.5.0;
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
@Aboudjem
Aboudjem / extract-address-from-tx.js
Created March 22, 2023 15:31
Function to extract the public key and address associated to a transaction
const { ethers } = require("ethers");
// Function to extract the address associated with to a transaction
async function getPublicKeyFromTransactionHash(provider, txHash) {
// Fetch the transaction using the transaction hash and provier
const tx = await provider.getTransaction(txHash);
// Extract the all the relevant fields from the transaction (We need all of them)
const unsignedTx = {
gasLimit: tx.gasLimit,