Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
RegistrationDelegate
Compiler Version
v0.8.30+commit.73712a01
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./IAgentRegistry.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
/**
* @title RegistrationDelegate
* @notice Contract that EOAs delegate to via EIP-7702 for sponsored registration
* @dev When an EOA delegates to this contract via EIP-7702, calls to the EOA
* execute this code in the EOA's context. msg.sender becomes the EOA's address.
*
* Flow:
* 1. Agent (EOA) signs EIP-7702 authorization delegating to this contract
* 2. Agent signs EIP-712 registration intent (agentURI, deadline)
* 3. Sponsor creates type-4 tx with agent's auth, calls EOA.executeRegistration(...)
* 4. This code executes in EOA's context, registers agent on ERC-8004
* 5. Agent owns the NFT, sponsor paid the gas
*/
contract RegistrationDelegate {
using ECDSA for bytes32;
using MessageHashUtils for bytes32;
IAgentRegistry public immutable registry;
// Domain separator for EIP-712
bytes32 public immutable DOMAIN_SEPARATOR;
// Typehash for registration intent
bytes32 public constant REGISTRATION_TYPEHASH = keccak256(
"Registration(string agentURI,uint256 deadline,uint256 nonce)"
);
// Nonces for replay protection (in the context of delegated EOA)
// Note: When delegated, this maps to storage slot in the EOA
mapping(address => uint256) public nonces;
event RegistrationExecuted(
address indexed agent,
uint256 indexed agentId,
string agentURI,
address indexed sponsor
);
constructor(address _registry) {
registry = IAgentRegistry(_registry);
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256("AgentRegistrationDelegate"),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/**
* @notice Execute registration on behalf of the delegating EOA
* @dev This function executes in the context of the delegating EOA.
* When called, `address(this)` = the agent's EOA address.
* The agent must have signed a registration intent to authorize this.
*
* @param agentURI The URI for the agent's registration file
* @param deadline Timestamp after which the signature expires
* @param signature Agent's EIP-712 signature authorizing this registration
* @return agentId The ID of the newly registered agent
*/
function executeRegistration(
string calldata agentURI,
uint256 deadline,
bytes calldata signature
) external returns (uint256 agentId) {
require(block.timestamp <= deadline, "Registration expired");
// In delegated execution, address(this) is the agent's EOA
address agent = address(this);
// Get nonce for this agent (stored in EOA's storage when delegated)
uint256 nonce = nonces[agent];
// Construct the EIP-712 digest
bytes32 structHash = keccak256(
abi.encode(
REGISTRATION_TYPEHASH,
keccak256(bytes(agentURI)),
deadline,
nonce
)
);
bytes32 digest = keccak256(
abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, structHash)
);
// Recover signer and verify it matches the agent EOA
address signer = digest.recover(signature);
require(signer == agent, "Invalid signature");
// Increment nonce
nonces[agent] = nonce + 1;
// Register the agent - msg.sender will be the sponsor's tx destination (agent's EOA)
// Since we're executing as the EOA, the registry sees us as the owner
agentId = registry.register(agentURI);
// tx.origin is the sponsor who submitted the transaction
emit RegistrationExecuted(agent, agentId, agentURI, tx.origin);
}
/**
* @notice Simple registration without additional signature verification
* @dev Use this when the EIP-7702 authorization alone is sufficient trust
* The agent has already signed the 7702 auth, proving intent to register
*
* @param agentURI The URI for the agent's registration file
* @return agentId The ID of the newly registered agent
*/
function executeSimpleRegistration(
string calldata agentURI
) external returns (uint256 agentId) {
address agent = address(this);
agentId = registry.register(agentURI);
emit RegistrationExecuted(agent, agentId, agentURI, tx.origin);
}
/**
* @notice Get the next nonce for an agent
* @dev Useful for constructing the registration intent off-chain
*/
function getNonce(address agent) external view returns (uint256) {
return nonces[agent];
}
/**
* @notice Compute the registration digest for off-chain signing
*/
function getRegistrationDigest(
string calldata agentURI,
uint256 deadline,
uint256 nonce
) external view returns (bytes32) {
bytes32 structHash = keccak256(
abi.encode(
REGISTRATION_TYPEHASH,
keccak256(bytes(agentURI)),
deadline,
nonce
)
);
return keccak256(
abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, structHash)
);
}
}// 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);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)
pragma solidity ^0.8.20;
import {Strings} from "../Strings.sol";
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title IAgentRegistry
* @notice Minimal interface for ERC-8004 Agent Identity Registry
* @dev Based on https://eips.ethereum.org/EIPS/eip-8004
*/
interface IAgentRegistry {
struct MetadataEntry {
string metadataKey;
bytes metadataValue;
}
event Registered(uint256 indexed agentId, string agentURI, address indexed owner);
event URIUpdated(uint256 indexed agentId, string newURI, address indexed updatedBy);
event MetadataSet(uint256 indexed agentId, string indexed indexedMetadataKey, string metadataKey, bytes metadataValue);
/// @notice Register a new agent with URI and metadata
function register(string calldata agentURI, MetadataEntry[] calldata metadata) external returns (uint256 agentId);
/// @notice Register a new agent with just URI
function register(string calldata agentURI) external returns (uint256 agentId);
/// @notice Register a new agent (URI added later)
function register() external returns (uint256 agentId);
/// @notice Update the agent's URI
function setAgentURI(uint256 agentId, string calldata newURI) external;
/// @notice Get the agent wallet address
function getAgentWallet(uint256 agentId) external view returns (address);
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"agent","type":"address"},{"indexed":true,"internalType":"uint256","name":"agentId","type":"uint256"},{"indexed":false,"internalType":"string","name":"agentURI","type":"string"},{"indexed":true,"internalType":"address","name":"sponsor","type":"address"}],"name":"RegistrationExecuted","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REGISTRATION_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"agentURI","type":"string"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"executeRegistration","outputs":[{"internalType":"uint256","name":"agentId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"agentURI","type":"string"}],"name":"executeSimpleRegistration","outputs":[{"internalType":"uint256","name":"agentId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"agent","type":"address"}],"name":"getNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"agentURI","type":"string"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"getRegistrationDigest","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"contract IAgentRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60c060405234801561001057600080fd5b50604051610bf5380380610bf583398101604081905261002f916100e8565b6001600160a01b0381166080908152604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527fd59fa1b2d66e603d5eeb1bfddf5b254c7831ce26f5bd3acf9a6dd64025475881918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015246918101919091523060a082015260c00160408051601f19818403018152919052805160209091012060a05250610118565b6000602082840312156100fa57600080fd5b81516001600160a01b038116811461011157600080fd5b9392505050565b60805160a051610a9c6101596000396000818161012e0152818161031e015261044f015260008181610155015281816101cb015261056d0152610a9c6000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80632ead9b6e1161005b5780632ead9b6e146101165780633644e515146101295780637b103999146101505780637ecebe001461018f57600080fd5b80631494e2f61461008d5780632a17e291146100c75780632d0335ab146100da5780632dc70e6414610103575b600080fd5b6100b47f9e80b0cc9e15a74bd63b2b44dd6bc71495a3d2e54ad656eb0e9a17db3efcf43981565b6040519081526020015b60405180910390f35b6100b46100d5366004610895565b6101af565b6100b46100e83660046108d7565b6001600160a01b031660009081526020819052604090205490565b6100b4610111366004610907565b61029c565b6100b4610124366004610958565b61036b565b6100b47f000000000000000000000000000000000000000000000000000000000000000081565b6101777f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100be565b6100b461019d3660046108d7565b60006020819052908152604090205481565b6040516379614c5f60e11b815260009030906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f2c298be9061020290879087906004016109d7565b6020604051808303816000875af1158015610221573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102459190610a06565b9150326001600160a01b031682826001600160a01b03167fa08604139969c8da239ec1b2084482765d324159653757c9769906c92473c7f6878760405161028d9291906109d7565b60405180910390a45092915050565b6000807f9e80b0cc9e15a74bd63b2b44dd6bc71495a3d2e54ad656eb0e9a17db3efcf43986866040516102d0929190610a1f565b604080519182900382206020808401949094528282015260608201969096526080808201959095528551808203909501855260a08101865284519482019490942061190160f01b60c08601527f000000000000000000000000000000000000000000000000000000000000000060c286015260e280860191909152855180860390910181526101029094019094525050805191012092915050565b6000834211156103b95760405162461bcd60e51b8152602060048201526014602482015273149959da5cdd1c985d1a5bdb88195e1c1a5c995960621b60448201526064015b60405180910390fd5b306000818152602081905260408082205490519091907f9e80b0cc9e15a74bd63b2b44dd6bc71495a3d2e54ad656eb0e9a17db3efcf439906103fe908b908b90610a1f565b604080519182900382206020830193909352810191909152606081018890526080810183905260a00160408051601f1981840301815290829052805160209182012061190160f01b918301919091527f0000000000000000000000000000000000000000000000000000000000000000602283015260428201819052915060009060620160405160208183030381529060405280519060200120905060006104de88888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525086939250506106479050565b9050846001600160a01b0316816001600160a01b0316146105355760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b60448201526064016103b0565b610540846001610a2f565b6001600160a01b03808716600090815260208190526040908190209290925590516379614c5f60e11b81527f00000000000000000000000000000000000000000000000000000000000000009091169063f2c298be906105a6908e908e906004016109d7565b6020604051808303816000875af11580156105c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e99190610a06565b9550326001600160a01b031686866001600160a01b03167fa08604139969c8da239ec1b2084482765d324159653757c9769906c92473c7f68e8e6040516106319291906109d7565b60405180910390a4505050505095945050505050565b6000806000806106578686610673565b92509250925061066782826106c0565b50909150505b92915050565b600080600083516041036106ad5760208401516040850151606086015160001a61069f8882858561077d565b9550955095505050506106b9565b50508151600091506002905b9250925092565b60008260038111156106d4576106d4610a50565b036106dd575050565b60018260038111156106f1576106f1610a50565b0361070f5760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561072357610723610a50565b036107445760405163fce698f760e01b8152600481018290526024016103b0565b600382600381111561075857610758610a50565b03610779576040516335e2f38360e21b8152600481018290526024016103b0565b5050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156107b85750600091506003905082610842565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561080c573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661083857506000925060019150829050610842565b9250600091508190505b9450945094915050565b60008083601f84011261085e57600080fd5b50813567ffffffffffffffff81111561087657600080fd5b60208301915083602082850101111561088e57600080fd5b9250929050565b600080602083850312156108a857600080fd5b823567ffffffffffffffff8111156108bf57600080fd5b6108cb8582860161084c565b90969095509350505050565b6000602082840312156108e957600080fd5b81356001600160a01b038116811461090057600080fd5b9392505050565b6000806000806060858703121561091d57600080fd5b843567ffffffffffffffff81111561093457600080fd5b6109408782880161084c565b90989097506020870135966040013595509350505050565b60008060008060006060868803121561097057600080fd5b853567ffffffffffffffff81111561098757600080fd5b6109938882890161084c565b90965094505060208601359250604086013567ffffffffffffffff8111156109ba57600080fd5b6109c68882890161084c565b969995985093965092949392505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b600060208284031215610a1857600080fd5b5051919050565b8183823760009101908152919050565b8082018082111561066d57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fdfea26469706673582212205e8d55b55a106f6436a76a41341304796b859013b5ee8a4f2c6702c23f8169ff64736f6c634300081e00330000000000000000000000008004a169fb4a3325136eb29fa0ceb6d2e539a432
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80632ead9b6e1161005b5780632ead9b6e146101165780633644e515146101295780637b103999146101505780637ecebe001461018f57600080fd5b80631494e2f61461008d5780632a17e291146100c75780632d0335ab146100da5780632dc70e6414610103575b600080fd5b6100b47f9e80b0cc9e15a74bd63b2b44dd6bc71495a3d2e54ad656eb0e9a17db3efcf43981565b6040519081526020015b60405180910390f35b6100b46100d5366004610895565b6101af565b6100b46100e83660046108d7565b6001600160a01b031660009081526020819052604090205490565b6100b4610111366004610907565b61029c565b6100b4610124366004610958565b61036b565b6100b47f682f0d6c0f690415f7d3ef79169b2041286e14ba6591a79d333fba0c9a54533981565b6101777f0000000000000000000000008004a169fb4a3325136eb29fa0ceb6d2e539a43281565b6040516001600160a01b0390911681526020016100be565b6100b461019d3660046108d7565b60006020819052908152604090205481565b6040516379614c5f60e11b815260009030906001600160a01b037f0000000000000000000000008004a169fb4a3325136eb29fa0ceb6d2e539a432169063f2c298be9061020290879087906004016109d7565b6020604051808303816000875af1158015610221573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102459190610a06565b9150326001600160a01b031682826001600160a01b03167fa08604139969c8da239ec1b2084482765d324159653757c9769906c92473c7f6878760405161028d9291906109d7565b60405180910390a45092915050565b6000807f9e80b0cc9e15a74bd63b2b44dd6bc71495a3d2e54ad656eb0e9a17db3efcf43986866040516102d0929190610a1f565b604080519182900382206020808401949094528282015260608201969096526080808201959095528551808203909501855260a08101865284519482019490942061190160f01b60c08601527f682f0d6c0f690415f7d3ef79169b2041286e14ba6591a79d333fba0c9a54533960c286015260e280860191909152855180860390910181526101029094019094525050805191012092915050565b6000834211156103b95760405162461bcd60e51b8152602060048201526014602482015273149959da5cdd1c985d1a5bdb88195e1c1a5c995960621b60448201526064015b60405180910390fd5b306000818152602081905260408082205490519091907f9e80b0cc9e15a74bd63b2b44dd6bc71495a3d2e54ad656eb0e9a17db3efcf439906103fe908b908b90610a1f565b604080519182900382206020830193909352810191909152606081018890526080810183905260a00160408051601f1981840301815290829052805160209182012061190160f01b918301919091527f682f0d6c0f690415f7d3ef79169b2041286e14ba6591a79d333fba0c9a545339602283015260428201819052915060009060620160405160208183030381529060405280519060200120905060006104de88888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525086939250506106479050565b9050846001600160a01b0316816001600160a01b0316146105355760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b60448201526064016103b0565b610540846001610a2f565b6001600160a01b03808716600090815260208190526040908190209290925590516379614c5f60e11b81527f0000000000000000000000008004a169fb4a3325136eb29fa0ceb6d2e539a4329091169063f2c298be906105a6908e908e906004016109d7565b6020604051808303816000875af11580156105c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e99190610a06565b9550326001600160a01b031686866001600160a01b03167fa08604139969c8da239ec1b2084482765d324159653757c9769906c92473c7f68e8e6040516106319291906109d7565b60405180910390a4505050505095945050505050565b6000806000806106578686610673565b92509250925061066782826106c0565b50909150505b92915050565b600080600083516041036106ad5760208401516040850151606086015160001a61069f8882858561077d565b9550955095505050506106b9565b50508151600091506002905b9250925092565b60008260038111156106d4576106d4610a50565b036106dd575050565b60018260038111156106f1576106f1610a50565b0361070f5760405163f645eedf60e01b815260040160405180910390fd5b600282600381111561072357610723610a50565b036107445760405163fce698f760e01b8152600481018290526024016103b0565b600382600381111561075857610758610a50565b03610779576040516335e2f38360e21b8152600481018290526024016103b0565b5050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411156107b85750600091506003905082610842565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561080c573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661083857506000925060019150829050610842565b9250600091508190505b9450945094915050565b60008083601f84011261085e57600080fd5b50813567ffffffffffffffff81111561087657600080fd5b60208301915083602082850101111561088e57600080fd5b9250929050565b600080602083850312156108a857600080fd5b823567ffffffffffffffff8111156108bf57600080fd5b6108cb8582860161084c565b90969095509350505050565b6000602082840312156108e957600080fd5b81356001600160a01b038116811461090057600080fd5b9392505050565b6000806000806060858703121561091d57600080fd5b843567ffffffffffffffff81111561093457600080fd5b6109408782880161084c565b90989097506020870135966040013595509350505050565b60008060008060006060868803121561097057600080fd5b853567ffffffffffffffff81111561098757600080fd5b6109938882890161084c565b90965094505060208601359250604086013567ffffffffffffffff8111156109ba57600080fd5b6109c68882890161084c565b969995985093965092949392505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b600060208284031215610a1857600080fd5b5051919050565b8183823760009101908152919050565b8082018082111561066d57634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fdfea26469706673582212205e8d55b55a106f6436a76a41341304796b859013b5ee8a4f2c6702c23f8169ff64736f6c634300081e0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000008004a169fb4a3325136eb29fa0ceb6d2e539a432
-----Decoded View---------------
Arg [0] : _registry (address): 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000008004a169fb4a3325136eb29fa0ceb6d2e539a432
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.