Sepolia Testnet

Contract

0x75982eBc73a9Fc60d4CBbb4be8CF301bfC032976

Overview

ETH Balance

0 ETH

Multichain Info

N/A
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x33e62296...1c0A22DfA
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
SampleAttestation

Compiler Version
v0.8.26+commit.8a97fa7a

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 3 : Attestation.sol
// SPDX-License-Identifier: APACHE-2.0
pragma solidity ^0.8.20;

import {Proof} from "./Proof.sol";
import {ProofVerifier} from "./ProofVerifier.sol";

struct Attestation {
    bytes32 uid;
    bytes32 schema;
    bytes32 uHash;
    address recipient;
    bytes32 publicFieldsHash;
}

contract SampleAttestation is ProofVerifier {
    mapping(bytes32 uid => Attestation) private attestations;
    mapping(address => bytes32 uid) private attestedAddresses;

	address public owner;

    string private secret = "bad Secret";

    constructor(string memory _newSecret) ProofVerifier() {
		owner = msg.sender;
		secret = _newSecret;
	}

    function attest(bytes memory _proofAsBytes) public returns (string memory) {
        Proof memory _proof = abi.decode(_proofAsBytes, (Proof));
        require(verify(_proof), "verify proof fail");

        Attestation memory attestation = Attestation({
            uid: 0,
            schema: _proof.schemaId,
            uHash: _proof.uHash,
            recipient: _proof.recipient,
            publicFieldsHash: _proof.publicFieldsHash
        });

        bytes32 uid;
        uint32 bump = 0;
        while (true) {
            uid = getUID(attestation, bump);
            if (attestations[uid].uid == 0) {
                break;
            }

            unchecked {
                ++bump;
            }
        }

        attestation.uid = uid;

        attestations[uid] = attestation;
        attestedAddresses[_proof.recipient] = uid;
        return secret;
    }

    function getAttestationFromAddress(address _recipient) public view returns (Attestation memory) {
        return attestations[attestedAddresses[_recipient]];
    }

    function getAttestation(bytes32 uid) public view returns (Attestation memory) {
        return attestations[uid];
    }

    function getUID(Attestation memory attestation, uint32 bump) private pure returns (bytes32) {
        return keccak256(
            abi.encodePacked(
                attestation.schema, attestation.uHash, attestation.recipient, attestation.publicFieldsHash, bump
            )
        );
    }
}

File 2 of 3 : Proof.sol
// SPDX-License-Identifier: APACHE-2.0
pragma solidity ^0.8.20;

struct Proof {
    bytes32 taskId;
    bytes32 schemaId;
    bytes32 uHash;
    address recipient;
    bytes32 publicFieldsHash;
    address validator;
    bytes allocatorSignature;
    bytes validatorSignature;
}

File 3 of 3 : ProofVerifier.sol
// SPDX-License-Identifier: APACHE-2.0
pragma solidity ^0.8.20;

import {Proof} from "./Proof.sol";

contract ProofVerifier {
    address public defaultAllocator = 0x19a567b3b212a5b35bA0E3B600FbEd5c2eE9083d;

    constructor() {}

    function verify(Proof memory _proof) public view returns (bool) {
        return (
            verifyAllocatorSignature(_proof.taskId, _proof.schemaId, _proof.validator, _proof.allocatorSignature)
                && verifyValidatorSignature(
                    _proof.taskId,
                    _proof.schemaId,
                    _proof.uHash,
                    _proof.recipient,
                    _proof.publicFieldsHash,
                    _proof.validator,
                    _proof.validatorSignature
                )
        );
    }

    function verifyAllocatorSignature(
        bytes32 _taskId,
        bytes32 _schemaId,
        address _validator,
        bytes memory _allocatorSignature
    ) public view returns (bool) {
        bytes32 hashed = keccak256(abi.encode(_taskId, _schemaId, _validator));
        address allocator = recoverSigner(prefixed(hashed), _allocatorSignature);

        return (allocator == defaultAllocator);
    }

    function verifyValidatorSignature(
        bytes32 _taskId,
        bytes32 _schemaId,
        bytes32 _uHash,
        address _recipient,
        bytes32 _publicFieldsHash,
        address _validator,
        bytes memory _validatorSignature
    ) public pure returns (bool) {
        bytes32 hashed = keccak256(abi.encode(_taskId, _schemaId, _uHash, _publicFieldsHash, _recipient));
        address validator = recoverSigner(prefixed(hashed), _validatorSignature);

        return (validator == _validator);
    }

    function prefixed(bytes32 hash) private pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    function recoverSigner(bytes32 _hash, bytes memory _signature) private pure returns (address signer) {
        require(_signature.length == 65, "Invalid signature length");
        bytes32 r;
        bytes32 s;
        uint8 v;
        assembly {
            r := mload(add(_signature, 0x20))
            s := mload(add(_signature, 0x40))
            v := byte(0, mload(add(_signature, 0x60)))
        }
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            revert("SignatureValidator#recoverSigner: invalid signature 's' value");
        }

        if (v != 27 && v != 28) {
            revert("SignatureValidator#recoverSigner: invalid signature 'v' value");
        }

        signer = ecrecover(_hash, v, r, s);
        // Prevent signer from being 0x0
        require(signer != address(0x0), "SignatureValidator#recoverSigner: INVALID_SIGNER");
        return signer;
    }
}

Settings
{
  "remappings": [
    "forge-std/=lib/forge-std/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "viaIR": false,
  "libraries": {}
}

Contract ABI

API
[{"inputs":[{"internalType":"string","name":"_newSecret","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes","name":"_proofAsBytes","type":"bytes"}],"name":"attest","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAllocator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"uid","type":"bytes32"}],"name":"getAttestation","outputs":[{"components":[{"internalType":"bytes32","name":"uid","type":"bytes32"},{"internalType":"bytes32","name":"schema","type":"bytes32"},{"internalType":"bytes32","name":"uHash","type":"bytes32"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes32","name":"publicFieldsHash","type":"bytes32"}],"internalType":"struct Attestation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"getAttestationFromAddress","outputs":[{"components":[{"internalType":"bytes32","name":"uid","type":"bytes32"},{"internalType":"bytes32","name":"schema","type":"bytes32"},{"internalType":"bytes32","name":"uHash","type":"bytes32"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes32","name":"publicFieldsHash","type":"bytes32"}],"internalType":"struct Attestation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"taskId","type":"bytes32"},{"internalType":"bytes32","name":"schemaId","type":"bytes32"},{"internalType":"bytes32","name":"uHash","type":"bytes32"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes32","name":"publicFieldsHash","type":"bytes32"},{"internalType":"address","name":"validator","type":"address"},{"internalType":"bytes","name":"allocatorSignature","type":"bytes"},{"internalType":"bytes","name":"validatorSignature","type":"bytes"}],"internalType":"struct Proof","name":"_proof","type":"tuple"}],"name":"verify","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_taskId","type":"bytes32"},{"internalType":"bytes32","name":"_schemaId","type":"bytes32"},{"internalType":"address","name":"_validator","type":"address"},{"internalType":"bytes","name":"_allocatorSignature","type":"bytes"}],"name":"verifyAllocatorSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_taskId","type":"bytes32"},{"internalType":"bytes32","name":"_schemaId","type":"bytes32"},{"internalType":"bytes32","name":"_uHash","type":"bytes32"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"bytes32","name":"_publicFieldsHash","type":"bytes32"},{"internalType":"address","name":"_validator","type":"address"},{"internalType":"bytes","name":"_validatorSignature","type":"bytes"}],"name":"verifyValidatorSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063756c6eed1161005b578063756c6eed146101e95780638da5cb5b146101fc578063a3112a641461020f578063b41454461461029857600080fd5b806303975ea91461008d57806308fb83961461017b5780631f97770c146101a6578063430768ab146101c9575b600080fd5b61012c61009b366004610922565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152506001600160a01b039081166000908152600260208181526040808420548452600180835293819020815160a081018352815481529481015492850192909252918101549183019190915260038101549092166060820152600490910154608082015290565b60405161017291908151815260208083015190820152604080830151908201526060808301516001600160a01b0316908201526080918201519181019190915260a00190565b60405180910390f35b60005461018e906001600160a01b031681565b6040516001600160a01b039091168152602001610172565b6101b96101b4366004610a35565b6102ab565b6040519015158152602001610172565b6101dc6101d7366004610a98565b61031b565b6040516101729190610af9565b6101b96101f7366004610b2c565b6104f3565b60035461018e906001600160a01b031681565b61012c61021d366004610c14565b6040805160a0808201835260008083526020808401829052838501829052606080850183905260809485018390529582526001808252918590208551938401865280548452918201549083015260028101549382019390935260038301546001600160a01b0316938101939093526004909101549082015290565b6101b96102a6366004610c2d565b610549565b60408051602081018690529081018490526001600160a01b0383166060820152600090819060800160405160208183030381529060405280519060200120905060006102ff6102f9836105c3565b85610616565b6000546001600160a01b03908116911614979650505050505050565b60606000828060200190518101906103339190610d06565b905061033e816104f3565b6103835760405162461bcd60e51b81526020600482015260116024820152701d995c9a599e481c1c9bdbd98819985a5b607a1b60448201526064015b60405180910390fd5b6040805160a08101825260008082526020848101519083015283830151928201929092526060808401516001600160a01b0316908201526080808401519082015290805b6103d18382610874565b600081815260016020526040902054909250156103f0576001016103c7565b8183526000828152600160208181526040808420875181558288015193810193909355808701516002808501919091556060808901516003860180546001600160a01b0319166001600160a01b0392831617905560808a0151600496870155908a0151168552909152909120839055805461046a90610de0565b80601f016020809104026020016040519081016040528092919081815260200182805461049690610de0565b80156104e35780601f106104b8576101008083540402835291602001916104e3565b820191906000526020600020905b8154815290600101906020018083116104c657829003601f168201915b5050505050945050505050919050565b6000610511826000015183602001518460a001518560c001516102ab565b80156105435750610543826000015183602001518460400151856060015186608001518760a001518860e00151610549565b92915050565b604080516020810189905290810187905260608101869052608081018490526001600160a01b03851660a0820152600090819060c00160405160208183030381529060405280519060200120905060006105a56102f9836105c3565b6001600160a01b039081169086161492505050979650505050505050565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b600081516041146106695760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e6774680000000000000000604482015260640161037a565b60208201516040830151606084015160001a7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156107115760405162461bcd60e51b815260206004820152603d60248201527f5369676e617475726556616c696461746f72237265636f7665725369676e657260448201527f3a20696e76616c6964207369676e6174757265202773272076616c7565000000606482015260840161037a565b8060ff16601b1415801561072957508060ff16601c14155b1561079c5760405162461bcd60e51b815260206004820152603d60248201527f5369676e617475726556616c696461746f72237265636f7665725369676e657260448201527f3a20696e76616c6964207369676e6174757265202776272076616c7565000000606482015260840161037a565b60408051600081526020810180835288905260ff831691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa1580156107ef573d6000803e3d6000fd5b5050604051601f1901519450506001600160a01b03841661086b5760405162461bcd60e51b815260206004820152603060248201527f5369676e617475726556616c696461746f72237265636f7665725369676e657260448201526f1d1024a72b20a624a22fa9a4a3a722a960811b606482015260840161037a565b50505092915050565b60008260200151836040015184606001518560800151856040516020016108dc959493929190948552602085019390935260609190911b6bffffffffffffffffffffffff19166040840152605483015260e01b6001600160e01b031916607482015260780190565b60405160208183030381529060405280519060200120905092915050565b6001600160a01b038116811461090f57600080fd5b50565b803561091d816108fa565b919050565b60006020828403121561093457600080fd5b813561093f816108fa565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051610100810167ffffffffffffffff8111828210171561098057610980610946565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156109af576109af610946565b604052919050565b600067ffffffffffffffff8211156109d1576109d1610946565b50601f01601f191660200190565b600082601f8301126109f057600080fd5b8135610a036109fe826109b7565b610986565b818152846020838601011115610a1857600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215610a4b57600080fd5b84359350602085013592506040850135610a64816108fa565b9150606085013567ffffffffffffffff811115610a8057600080fd5b610a8c878288016109df565b91505092959194509250565b600060208284031215610aaa57600080fd5b813567ffffffffffffffff811115610ac157600080fd5b610acd848285016109df565b949350505050565b60005b83811015610af0578181015183820152602001610ad8565b50506000910152565b6020815260008251806020840152610b18816040850160208701610ad5565b601f01601f19169190910160400192915050565b600060208284031215610b3e57600080fd5b813567ffffffffffffffff811115610b5557600080fd5b82016101008185031215610b6857600080fd5b610b7061095c565b813581526020808301359082015260408083013590820152610b9460608301610912565b606082015260808281013590820152610baf60a08301610912565b60a082015260c082013567ffffffffffffffff811115610bce57600080fd5b610bda868285016109df565b60c08301525060e082013567ffffffffffffffff811115610bfa57600080fd5b610c06868285016109df565b60e083015250949350505050565b600060208284031215610c2657600080fd5b5035919050565b600080600080600080600060e0888a031215610c4857600080fd5b8735965060208801359550604088013594506060880135610c68816108fa565b93506080880135925060a0880135610c7f816108fa565b915060c088013567ffffffffffffffff811115610c9b57600080fd5b610ca78a828b016109df565b91505092959891949750929550565b805161091d816108fa565b600082601f830112610cd257600080fd5b8151610ce06109fe826109b7565b818152846020838601011115610cf557600080fd5b610acd826020830160208701610ad5565b600060208284031215610d1857600080fd5b815167ffffffffffffffff811115610d2f57600080fd5b82016101008185031215610d4257600080fd5b610d4a61095c565b815181526020808301519082015260408083015190820152610d6e60608301610cb6565b606082015260808281015190820152610d8960a08301610cb6565b60a082015260c082015167ffffffffffffffff811115610da857600080fd5b610db486828501610cc1565b60c08301525060e082015167ffffffffffffffff811115610dd457600080fd5b610c0686828501610cc1565b600181811c90821680610df457607f821691505b602082108103610e1457634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212208f59ba9e34e8f72d31d18655d14987de30c8e098483c677882c334bb9e4bac7364736f6c634300081a0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.