Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError, bytes32) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}
"
},
"@openzeppelin/contracts/utils/cryptography/MerkleProof.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.20;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Sorts the pair (a, b) and hashes the result.
*/
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
"
},
"@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
"
},
"@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
"
},
"contracts/ExecutorStore.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.22;
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { SelfCallable } from "./lib/SelfCallable.sol";
/**
* @title ExecutorStore
* @notice Abstract contract that manages a set of executors and a whether they are required.
* @dev Uses EnumerableSet to store executor addresses
*/
abstract contract ExecutorStore is SelfCallable {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @dev Set of available executors for the MultiSig.
*/
EnumerableSet.AddressSet internal executorSet;
/**
* @notice Whether the executor permission is required to execute a transaction.
*/
bool public executorRequired;
/// @notice Error thrown when an executor address is invalid.
/// @dev This error is thrown when the address is zero.
error InvalidExecutor();
/// @notice Error thrown when attempting to add an execute who is already active.
/// @param executor The address of the executor.
error ExecutorAlreadyActive(address executor);
/// @notice Error thrown when attempting to remove an execute who is not found.
/// @param executor The address of the executor.
error ExecutorNotFound(address executor);
/**
* @notice Emitted when an executor's active status is updated.
* @param executor The address of the executor.
* @param active True if added, false if removed.
*/
event ExecutorSet(address indexed executor, bool active);
/**
* @notice Emitted when the executor required state is updated.
* @param required The new state
*/
event ExecutorRequiredSet(bool required);
/**
* @dev Initializes the ExecutorStore with a list of executors and sets whether executors are required.
* @param _executors Array of executor addresses, can be empty.
* @dev If the array is empty, executorsRequired will be set to false.
*/
constructor(address[] memory _executors, bool _executorRequired) {
for (uint256 i = 0; i < _executors.length; i++) {
_addExecutor(_executors[i]);
}
_setExecutorRequired(_executorRequired);
}
/**
* @dev Sets whether executors are required.
* @param _executorRequired The new threshold value.
*/
function setExecutorRequired(bool _executorRequired) external onlySelfCall {
_setExecutorRequired(_executorRequired);
}
/**
* @dev Internal function to set whether executors are required for this MultiSig.
* @param _executorRequired The new value.
*/
function _setExecutorRequired(bool _executorRequired) internal {
executorRequired = _executorRequired;
emit ExecutorRequiredSet(_executorRequired);
}
/**
* @notice Adds or removes an executor from this MultiSig.
* @dev Only callable via the MultiSig contract itself.
* @param _executor The address of the executor to add/remove.
* @param _active True to add executor, false to remove executor.
*/
function setExecutor(address _executor, bool _active) external onlySelfCall {
if (_active) {
_addExecutor(_executor);
} else {
_removeExecutor(_executor);
}
}
/**
* @dev Internal function to add an executor.
* @param _executor The address of the executor to add.
*/
function _addExecutor(address _executor) internal {
if (_executor == address(0)) revert InvalidExecutor();
if (!executorSet.add(_executor)) revert ExecutorAlreadyActive(_executor);
emit ExecutorSet(_executor, true);
}
/**
* @dev Internal function to remove an executor.
* @param _executor The address of the executor to remove.
*/
function _removeExecutor(address _executor) internal {
if (!executorSet.remove(_executor)) revert ExecutorNotFound(_executor);
emit ExecutorSet(_executor, false);
}
/**
* @notice Returns the list of all active executors.
* @return An array of addresses representing the current set of executors.
*/
function getExecutors() public view returns (address[] memory) {
return executorSet.values();
}
/**
* @notice Checks if a given address is in the set of executors.
* @param _executor The address to check.
* @return True if the address is a executor, otherwise false.
*/
function isExecutor(address _executor) public view returns (bool) {
return executorSet.contains(_executor);
}
/**
* @notice Returns the total number of active executors.
* @return The number of executors currently active.
*/
function totalExecutors() public view returns (uint256) {
return executorSet.length();
}
}
"
},
"contracts/lib/SelfCallable.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.22;
abstract contract SelfCallable {
/// @notice Error thrown when attempting to call a function from an invalid address.
error OnlySelfCall();
/**
* @dev Restricts access to functions so they can only be called via this contract itself.
*/
modifier onlySelfCall() {
if (msg.sender != address(this)) revert OnlySelfCall();
_;
}
}
"
},
"contracts/MultiSig.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.22;
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { SelfCallable } from "./lib/SelfCallable.sol";
/**
* @title MultiSig
* @notice Abstract contract that manages a set of signers and a signature threshold.
* Designed to be inherited by contracts requiring multi-signature verification.
* @dev Uses EnumerableSet to store signer addresses and ECDSA for signature recovery.
*/
abstract contract MultiSig is SelfCallable {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @dev Set of available signers for the MultiSig.
*/
EnumerableSet.AddressSet internal signerSet;
/**
* @notice The number of signatures required to execute a transaction.
*/
uint256 public threshold;
/// @notice Error thrown when a signer address is invalid.
error InvalidSigner();
/// @notice Error thrown when the threshold is set to zero.
error ZeroThreshold();
/// @notice Error thrown when the total number of signers is less than the threshold.
/// @param totalSigners The current number of signers.
/// @param threshold The required threshold.
error TotalSignersLessThanThreshold(uint256 totalSigners, uint256 threshold);
/// @notice Error thrown when attempting to add a signer who is already active.
/// @param signer The address of the signer.
error SignerAlreadyAdded(address signer);
/// @notice Error thrown when attempting to remove a signer who is not found.
/// @param signer The address of the signer.
error SignerNotFound(address signer);
/// @notice Error thrown when there is a signature format error or mismatch in length.
error SignatureError();
/// @notice Error thrown when signers are not sorted in ascending order (prevents duplicates).
error UnsortedSigners();
/**
* @notice Emitted when a signer's active status is updated.
* @param signer The address of the signer.
* @param active True if added, false if removed.
*/
event SignerSet(address indexed signer, bool active);
/**
* @notice Emitted when the threshold for signatures is set.
* @param threshold The new threshold.
*/
event ThresholdSet(uint256 threshold);
/**
* @dev The length of a single signature in bytes (r=32, s=32, v=1).
*/
uint8 constant SIGNATURE_LENGTH = 65;
/**
* @dev Initializes the MultiSig with a list of signers and sets the signature threshold.
* @param _signers Array of signer addresses.
* @param _threshold The initial threshold for signatures.
*/
constructor(address[] memory _signers, uint256 _threshold) {
for (uint256 i = 0; i < _signers.length; i++) {
_addSigner(_signers[i]);
}
_setThreshold(_threshold);
}
/**
* @notice Allows the MultiSig contract to update the signature threshold.
* @dev This function can only be called by the MultiSig contract itself.
* @param _threshold The new threshold value.
*/
function setThreshold(uint256 _threshold) external onlySelfCall {
_setThreshold(_threshold);
}
/**
* @dev Internal function to set the threshold for this MultiSig.
* - The threshold must be greater than zero.
* - The threshold must be less than or equal to the number of signers.
* @param _threshold The new threshold value.
*/
function _setThreshold(uint256 _threshold) internal {
if (_threshold == 0) revert ZeroThreshold();
if (totalSigners() < _threshold) revert TotalSignersLessThanThreshold(totalSigners(), _threshold);
threshold = _threshold;
emit ThresholdSet(_threshold);
}
/**
* @notice Adds or removes a signer from this MultiSig.
* @dev Only callable via the MultiSig contract itself.
* @param _signer The address of the signer to add/remove.
* @param _active True to add signer, false to remove signer.
*/
function setSigner(address _signer, bool _active) external onlySelfCall {
if (_active) {
_addSigner(_signer);
} else {
_removeSigner(_signer);
}
}
/**
* @dev Internal function to add a signer.
* - `address(0)` is not a valid signer.
* - A signer cannot be added twice.
* @param _signer The address of the signer to add.
*/
function _addSigner(address _signer) internal {
if (_signer == address(0)) revert InvalidSigner();
if (!signerSet.add(_signer)) revert SignerAlreadyAdded(_signer);
emit SignerSet(_signer, true);
}
/**
* @dev Internal function to remove a signer.
* - Signer must be part of the existing set of signers.
* - The threshold must be less than or equal to the number of remaining signers.
* @param _signer The address of the signer to remove.
*/
function _removeSigner(address _signer) internal {
if (!signerSet.remove(_signer)) revert SignerNotFound(_signer);
if (totalSigners() < threshold) revert TotalSignersLessThanThreshold(totalSigners(), threshold);
emit SignerSet(_signer, false);
}
/**
* @notice Verifies signatures on a given digest against the threshold.
* @dev Verifies that exactly `threshold` signatures are present, sorted by ascending signer addresses.
* @param _digest The message digest (hash) being signed.
* @param _signatures The concatenated signatures.
*/
function verifySignatures(bytes32 _digest, bytes calldata _signatures) public view {
verifyNSignatures(_digest, _signatures, threshold);
}
/**
* @notice Verifies N signatures on a given digest.
* @dev Reverts if:
* - The threshold passed is zero.
* - The number of signatures doesn't match N (each signature is 65 bytes).
* - The signers are not strictly increasing (to prevent duplicates).
* - Any signer is not in the set of authorized signers.
* @param _digest The message digest (hash) being signed.
* @param _signatures The concatenated signatures.
* @param _threshold The required number of valid signatures.
*/
function verifyNSignatures(bytes32 _digest, bytes calldata _signatures, uint256 _threshold) public view {
if (_threshold == 0) revert ZeroThreshold();
// Each signature is SIGNATURE_LENGTH (65) bytes (r=32, s=32, v=1).
if ((_signatures.length % SIGNATURE_LENGTH) != 0) revert SignatureError();
uint256 signaturesCount = _signatures.length / SIGNATURE_LENGTH;
if (signaturesCount < _threshold) revert SignatureError();
// There cannot be a signer with address 0, so we start with address(0) to ensure ascending order.
address lastSigner = address(0);
for (uint256 i = 0; i < signaturesCount; i++) {
// Extract a single signature (SIGNATURE_LENGTH (65) bytes) at a time.
bytes calldata signature = _signatures[i * SIGNATURE_LENGTH:(i + 1) * SIGNATURE_LENGTH];
address currentSigner = ECDSA.recover(_digest, signature);
// Check ordering to avoid duplicates and ensure strictly increasing addresses.
if (currentSigner <= lastSigner) revert UnsortedSigners();
// Check if the signer is in our set.
if (!isSigner(currentSigner)) revert SignerNotFound(currentSigner);
lastSigner = currentSigner;
}
}
/**
* @notice Returns the list of all active signers.
* @return An array of addresses representing the current set of signers.
*/
function getSigners() public view returns (address[] memory) {
return signerSet.values();
}
/**
* @notice Checks if a given address is in the set of signers.
* @param _signer The address to check.
* @return True if the address is a signer, otherwise false.
*/
function isSigner(address _signer) public view returns (bool) {
return signerSet.contains(_signer);
}
/**
* @notice Returns the total number of active signers.
* @return The number of signers currently active.
*/
function totalSigners() public view returns (uint256) {
return signerSet.length();
}
}
"
},
"contracts/OneSig.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.22;
import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { MultiSig } from "./MultiSig.sol";
import { ExecutorStore } from "./ExecutorStore.sol";
/**
* @title OneSig
* @author @TRileySchwarz, @Clearwood, @HansonYip, @mok-lz
* @notice A multi-chain enabled contract that uses a Merkle tree of transaction leaves.
* It allows transactions to be signed once (off-chain) and then executed on multiple chains,
* provided the Merkle proof is valid and the threshold of signers is met.
* @dev Inherits from MultiSig for signature threshold logic.
*/
contract OneSig is MultiSig, ReentrancyGuard, ExecutorStore {
/// @notice The version string of the OneSig contract.
string public constant VERSION = "0.0.1";
uint8 public constant LEAF_ENCODING_VERSION = 1;
/**
* @dev EIP-191 defines the format of the signature prefix.
* See https://eips.ethereum.org/EIPS/eip-191
*/
string private constant EIP191_PREFIX_FOR_EIP712 = "\x19\x01";
/**
* @dev EIP-712 domain separator type-hash.
* See https://eips.ethereum.org/EIPS/eip-712
*/
bytes32 private constant EIP712DOMAIN_TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/**
* @dev This domain separator is used to generate a signature hash for the merkle root,
* specifically using chainId = 1 (Ethereum Mainnet) and verifyingContract = 0xdEaD.
* This ensures that the same merkle root signatures can be used across different chains
* because they are all signed with this consistent "fake" domain.
*
* In other words, to verify the merkle root with the same signatures on different chains,
* we use the same chainId (1) and verifyingContract (0xdEaD) in the EIP-712 domain.
*/
bytes32 private constant DOMAIN_SEPARATOR =
keccak256(
abi.encode(
EIP712DOMAIN_TYPE_HASH,
keccak256(bytes("OneSig")), // this contract name
keccak256(bytes(VERSION)), // version
1, // Ethereum mainnet chainId
address(0xdEaD) // verifyingContract
)
);
/**
* @dev The type-hash of the data being signed to authorize a merkle root.
*/
bytes32 private constant SIGN_MERKLE_ROOT_TYPE_HASH =
keccak256("SignMerkleRoot(bytes32 seed,bytes32 merkleRoot,uint256 expiry)");
/**
* @notice The OneSig ID of the contract.
* @dev Because the oneSigId is part of the leaf, the same signatures can be used on different chains,
* while leaving each transaction to be targetted towards one
*/
uint64 public immutable ONE_SIG_ID;
/**
* @notice A random seed encoded into the signatures/root.
* @dev Allows for a previously signed, but unexecuted, transaction(s) to be 'revoked' by changing the seed.
*/
bytes32 public seed;
/**
* @notice A sequential nonce to prevent replay attacks and enforce transaction ordering.
*/
uint64 public nonce;
/// @notice Emitted when the seed is updated.
event SeedSet(bytes32 seed);
/// @notice Emitted when a transaction is executed.
/// @param merkleRoot The merkle root used to authorize the transaction.
/// @param nonce The nonce of the transaction.
event TransactionExecuted(bytes32 merkleRoot, uint256 nonce);
/// @notice Error thrown when a merkle proof is invalid or the nonce does not match the expected value.
error InvalidProofOrNonce();
/// @notice Error thrown when a merkle root has expired (past the _expiry timestamp).
error MerkleRootExpired();
/// @notice Error thrown when a call in the transaction array fails.
/// @param index The index of the failing call within the transaction.
error ExecutionFailed(uint256 index);
/// @notice Error thrown when a function is not called from an executor or signer.
error OnlyExecutorOrSigner();
/**
* @notice Call to be executed as part of a Transaction.calls.
* - OneSig -> [Arbitrary contract].
* - e.g., setPeer(dstEid, remoteAddress).
* @param to Address of the contract for this data to be 'called' on.
* @param value Amount of ether to send with this call.
* @param data Encoded data to be sent to the contract (calldata).
*/
struct Call {
address to;
uint256 value;
bytes data;
}
/**
* @notice Single call to the OneSig contract (address(this)).
* - EOA -> OneSig
* - This struct is 1:1 with a 'leaf' in the merkle tree.
* - Execution of the underlying calls are atomic.
* - Cannot be processed until the previous leaf (nonce-ordered) has been executed successfully.
* @param calls List of calls to be made.
* @param proof Merkle proof to verify the transaction.
*/
struct Transaction {
Call[] calls;
bytes32[] proof;
}
/**
* @dev Restricts access to functions so they can only be called via an executor, OR a multisig signer.
*/
modifier onlyExecutorOrSigner() {
if (!canExecuteTransaction(msg.sender)) revert OnlyExecutorOrSigner();
_;
}
/**
* @notice Constructor to initialize the OneSig contract.
* @dev Inherits MultiSig(_signers, _threshold).
* @param _oneSigId A unique identifier per deployment, (typically block.chainid).
* @param _signers The list of signers authorized to sign transactions.
* @param _threshold The initial threshold of signers required to execute a transaction.
* @param _executors The list of executors authorized to execute transactions.
* @param _executorRequired If executors are required to execute transactions.
* @param _seed The random seed to encode into the signatures/root.
*/
constructor(
uint64 _oneSigId,
address[] memory _signers,
uint256 _threshold,
address[] memory _executors,
bool _executorRequired,
bytes32 _seed
) MultiSig(_signers, _threshold) ExecutorStore(_executors, _executorRequired) {
ONE_SIG_ID = _oneSigId;
_setSeed(_seed);
}
/**
* @notice Internal method to set the contract's seed.
* @param _seed The new seed value.
*/
function _setSeed(bytes32 _seed) internal virtual {
seed = _seed;
emit SeedSet(_seed);
}
/**
* @notice Sets the contract's seed.
* @dev Only callable via MultiSig functionality (i.e., requires threshold signatures from signers).
* @param _seed The new seed value.
*/
function setSeed(bytes32 _seed) public virtual onlySelfCall {
_setSeed(_seed);
}
/**
* @notice Executes a single transaction (which corresponds to a leaf in the merkle tree) if valid signatures are provided.
* @dev '_transaction' corresponds 1:1 with a leaf. This function can be called by anyone (permissionless),
* provided the merkle root is verified with sufficient signatures.
* @param _transaction The transaction data struct, including calls and proof.
* @param _merkleRoot The merkle root that authorizes this transaction.
* @param _expiry The timestamp after which the merkle root expires.
* @param _signatures Signatures from signers that meet the threshold.
*/
function executeTransaction(
Transaction calldata _transaction,
bytes32 _merkleRoot,
uint256 _expiry,
bytes calldata _signatures
) public payable virtual nonReentrant onlyExecutorOrSigner {
// Verify the merkle root and signatures
verifyMerkleRoot(_merkleRoot, _expiry, _signatures);
// Verify that this transaction matches the merkle root (using its proof)
verifyTransactionProof(_merkleRoot, _transaction);
// Increment nonce before execution to prevent replay
uint256 n = nonce++;
// Execute all calls atomically
for (uint256 i = 0; i < _transaction.calls.length; i++) {
(bool success, ) = _transaction.calls[i].to.call{ value: _transaction.calls[i].value }(
_transaction.calls[i].data
);
// Revert if the call fails
if (!success) revert ExecutionFailed(i);
}
emit TransactionExecuted(_merkleRoot, n);
}
/**
* @notice Validates the signatures on a given merkle root.
* @dev Reverts if the merkle root is expired or signatures do not meet the threshold.
* @param _merkleRoot The merkle root to verify.
* @param _expiry The timestamp after which the merkle root becomes invalid.
* @param _signatures The provided signatures.
*/
function verifyMerkleRoot(bytes32 _merkleRoot, uint256 _expiry, bytes calldata _signatures) public view {
// Check expiry
if (block.timestamp > _expiry) revert MerkleRootExpired();
// Compute the EIP-712 hash
bytes32 digest = keccak256(
abi.encodePacked(
EIP191_PREFIX_FOR_EIP712,
DOMAIN_SEPARATOR,
keccak256(abi.encode(SIGN_MERKLE_ROOT_TYPE_HASH, seed, _merkleRoot, _expiry))
)
);
// Verify the threshold signatures
verifySignatures(digest, _signatures);
}
/**
* @notice Verifies that the provided merkle proof matches the current transaction leaf under the merkle root.
* @dev Reverts if the proof is invalid or the nonce doesn't match the expected value.
* @param _merkleRoot The merkle root being used.
* @param _transaction The transaction data containing proof and calls.
*/
function verifyTransactionProof(bytes32 _merkleRoot, Transaction calldata _transaction) public view {
bytes32 leaf = encodeLeaf(nonce, _transaction.calls);
bool valid = MerkleProof.verifyCalldata(_transaction.proof, _merkleRoot, leaf);
if (!valid) revert InvalidProofOrNonce();
}
/**
* @notice Double encodes the transaction leaf for inclusion in the merkle tree.
* @param _nonce The nonce of the transaction.
* @param _calls The calls to be made in this transaction.
* @return The keccak256 hash of the encoded leaf.
*/
function encodeLeaf(uint64 _nonce, Call[] calldata _calls) public view returns (bytes32) {
return
keccak256(
abi.encodePacked(
keccak256(
abi.encodePacked(
LEAF_ENCODING_VERSION,
ONE_SIG_ID,
bytes32(uint256(uint160(address(this)))), // convert address(this) into bytes32
_nonce,
abi.encode(_calls)
)
)
)
);
}
/**
* @notice Checks if the a given address can execute a transaction.
* @param _sender The address of the message sender.
* @return True if executeTransaction can be called by the executor, otherwise false.
*/
function canExecuteTransaction(address _sender) public view returns (bool) {
// If the flag is set to false, then ANYONE can execute permissionlessly, otherwise the msg.sender must be a executor, or a signer
return (!executorRequired || isExecutor(_sender) || isSigner(_sender));
}
/**
* @notice Fallback function to receive ether.
* @dev Allows the contract to accept ETH.
*/
receive() external payable {}
}
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
Submitted on: 2025-11-05 10:58:28
Comments
Log in to comment.
No comments yet.