bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 14쪽 중 12쪽
";
const info = await delegateSignRevokeAttestation(attestationId, {
chain: EvmChains.sepolia,
reason: "test",
delegationAccount: privateKeyToAccount(delegationPrivateKey),
});
const delegationRevokeAttestationRes = await client.revokeAttestation(
info.attestationId,
{
reason: info.reason,
delegationSignature: info.delegationSignature,
}
);
```
### Off-chain (Arweave) Mode
```tsx
import {
SignProtocolClient,
SpMode,
EvmChains,
OffChainSignType,
} from "@ethsign/sp-sdk";
import { privateKeyToAccount } from "viem/accounts";
const privateKey = "0xabc"; // Optional
const client = new SignProtocolClient(SpMode.OffChain, {
signType: OffChainSignType.EvmEip712,
account: privateKeyToAccount(privateKey), // Optional
apiKey: 'xxx', // Required, from https://developer.sign.global/
});
// Create schema
const schemaInfo = await client.createSchema({
name: "xxx",
data: [{ name: "name", type: "string" }],
});
// Create attestation
const attestationInfo = await client.createAttestation({
schemaId: "xxxx", // `schemaInfo.schemaId` or other `schemaId`
data: { name: "a" },
indexingValue: "xxx",
});
// Revoke attestation
const attestationId = "xxx";
const revokeAttestationRes = await client.revokeAttestation(attestationId, {
reason: "test",
});
```
# Changelog
See the full changelog [here](https://www.npmjs.com/package/@ethsign/sp-sdk#changelog).
# Smart Contract
# EVM
## Installation
```bash
npm i @ethsign/sign-protocol-evm -S
```
## Example Usage: Actually Met IRL
*Actually Met IRL* is a smart contract that only creates an attestation on EVM Sign Protocol for two people meeting in real life if both parties consent to this fact. In this example, we will demonstrate how to:
* Link your smart contract to an existing on-chain Sign Protocol deployment and schema
* Create an attestation programmatically
You can find the complete Foundry repository [here](https://github.com/EthSign/sign-protocol-evm-demo-0), a deployment of the example contract on Base Sepolia [here](https://sepolia.basescan.org/address/0x996a99676d286fCeFCc1920369548c62ff7d6D11), and the corresponding SignScan page [here](https://testnet-scan.sign.global/schema/onchain_evm_84532_0x12).
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { ISP } from "@ethsign/sign-protocol-evm/src/interfaces/ISP.sol";
import { Attestation } from "@ethsign/sign-protocol-evm/src/models/Attestation.sol";
import { DataLocation } from "@ethsign/sign-protocol-evm/src/models/DataLocation.sol";
contract ActuallyMetIRL is Ownable {
ISP public spInstance;
uint64 public schemaId;
mapping(address partyA => address partyB) public metIRLMapping;
error ConfirmationAddressMismatch();
event DidMeetIRL(address partyA, address partyB, uint64 attestationId);
constructor() Ownable(_msgSender()) { }
function setSPInstance(address instance) external onlyOwner {
spInstance = ISP(instance);
}
function setSchemaID(uint64 schemaId_) external onlyOwner {
schemaId = schemaId_;
}
function claimMetIRL(address partyB) external {
metIRLMapping[_msgSender()] = partyB;
}
function confirmMetIRL(address partyA, bytes memory data) external returns (uint64) {
address partyB = _msgSender();
if (metIRLMapping[partyA] == partyB) {
// B has confirm A's claim of having met them IRL
// We now make an attestation of having actually met IRL
bytes[] memory recipients = new bytes[](2);
recipients[0] = abi.encode(partyA);
recipients[1] = abi.encode(partyB);
Attestation memory a = Attestation({
schemaId: schemaId,
linkedAttestationId: 0,
attestTimestamp: 0,
revokeTimestamp: 0,
attester: address(this),
validUntil: 0,
dataLocation: DataLocation.ONCHAIN,
revoked: false,
recipients: recipients,
data: data // SignScan assumes this is from `abi.encode(...)`
});
uint64 attestationId = spInstance.attest(a, "", "", "");
emit DidMeetIRL(partyA, partyB, attestationId);
return attestationId;
} else {
revert ConfirmationAddressMismatch();
}
}
}
```
{% hint style="warning" %}
NOTE: `data` is expecting a value from `abi.encode()`. If your relevant schema is storing data on-chain, you need to encode the actual data you are trying to store. If you are storing data off-chain, such as IPFS, you will need to upload the data, in JSON format, to the storage provider first. Next, you will encode the resulting CID string and pass in this value as `data`.
{% endhint %}
# Changelog
All notable changes to the Sign Protocol EVM contract package are documented here.
## 1.1.4
* Hardened delegated signatures with EIP-712 domain binding, per-attester nonces, and deadlines.
* Added `delegationNonces(address)` and `getDelegatedAuthorizationDigest(...)` for delegated-action signing.
* Rejected legacy delegated signatures that do not use the new encoded `(nonce, deadline, signature)` format.
* Converted deployment and upgrade tooling from Hardhat scripts to Foundry scripts using the CREATE3 deployment template.
* Added deterministic SP implementation deployment and existing proxy upgrade scripts.
* Added `bun run patch:sp` for chain-aware proxy patching with Alchemy RPC URL derivation.
* Added optional proxy ownership transfer to `PROD_OWNER` after successful upgrades.
* Added standard JSON input for SP `1.1.4` contract verification.
* Removed legacy Hardhat, Prettier, and unused package tooling in favor of Bun and Foundry formatting.
## 1.1.3
* Removed `registerBatch` and related interface functions to reduce contract size.
* Added Soldeer support and refreshed Foundry dependency wiring.
* Added Monad testnet configuration and deployment metadata updates.
## 1.1.2
* Fixed linked-attestation validation behavior.
* Added missing revoked-attestation checks while attesting.
* Bumped the Solidity compiler configuration to `0.8.26`.
## 1.1.1
* Fixed schema existence checks.
## 1.1.0
* Added storage of schema and attestation timestamps.
* Added backward-compatible behavior for existing schema and attestation counters.
* Optimized SP core contract and interface types.
## 1.0.1
* Fixed incorrect data passed to hooks.
## 1.0.0
* Initial npm package release for Sign Protocol EVM contracts.
# Interfaces
# ISP
Version 1.0.0-beta18
## Events
### SchemaRegistered
```solidity
event SchemaRegistered(uint64 schemaId)
```
### AttestationMade
```solidity
event AttestationMade(uint64 attestationId, string indexingKey)
```
### AttestationRevoked
```solidity
event AttestationRevoked(uint64 attestationId, string reason)
```
### OffchainAttestationMade
```solidity
event OffchainAttestationMade(string attestationId)
```
### OffchainAttestationRevoked
```solidity
event OffchainAttestationRevoked(string attestationId, string reason)
```
## Errors
### SchemaNonexistent
```solidity
error SchemaNonexistent(uint64 nonexistentSchemaId)
```
*0x38f8c6c4*
### SchemaWrongRegistrant
```solidity
error SchemaWrongRegistrant(address expected, address actual)
```
*0x71984561*
### AttestationIrrevocable
```solidity
error AttestationIrrevocable(uint64 schemaId, uint64 offendingAttestationId)
```
*0x8ac42f49*
### AttestationNonexistent
```solidity
error AttestationNonexistent(uint64 nonexistentAttestationId)
```
*0x54681a13*
### AttestationInvalidDuration
```solidity
error AttestationInvalidDuration(uint64 offendingAttestationId, uint64 maxDuration, uint64 inputDuration)
```
*0xa65e02ed*
### AttestationAlreadyRevoked
```solidity
error AttestationAlreadyRevoked(uint64 offendingAttestationId)
```
*0xd8c3da86*
### AttestationWrongAttester
```solidity
error AttestationWrongAttester(address expected, address actual)
```
*0xa9ad2007*
### OffchainAttestationExists
```solidity
error OffchainAttestationExists(string existingOffchainAttestationId)
```
*0xc83e3cdf*
### OffchainAttestationNonexistent
```solidity
error OffchainAttestationNonexistent(string nonexistentOffchainAttestationId)
```
*0xa006519a*
### OffchainAttestationAlreadyRevoked
```solidity
error OffchainAttestationAlreadyRevoked(string offendingOffchainAttestationId)
```
*0xa0671d20*
### InvalidDelegateSignature
```solidity
error InvalidDelegateSignature()
```
*0xfdf4e6f9*
### LegacySPRequired
```solidity
error LegacySPRequired(address legacySP)
```
*0x5c34b9cc*
## Functions
### register
```solidity
function register(struct Schema schema, bytes delegateSignature) external returns (uint64 schemaId)
```
Registers a Schema.
*Emits `SchemaRegistered`.*
#### Parameters
| Name | Type | Description |
| ----------------- | ------------- | ------------- |
| schema | struct Schema | See `Schema`. |
| delegateSignature | bytes | |
#### Return Values
| Name | Type | Description |
| -------- | ------ | ----------------------------------------- |
| schemaId | uint64 | The assigned ID of the registered schema. |
### attest
```solidity
function attest(struct Attestation attestation, string indexingKey, bytes delegateSignature, bytes extraData) external returns (uint64 attestationId)
```
Makes an attestation.
*Emits `AttestationMade`.*
#### Parameters
| Name | Type | Description |
| ----------------- | ------------------ | --------------------------------------------------------------------------------------------------- |
| attestation | struct Attestation | See `Attestation`. |
| indexingKey | string | Used by the frontend to aid indexing. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated attestation. Use `""` or `0x` otherwise. |
| extraData | bytes | This is forwarded to the resolver directly. |
#### Return Values
| Name | Type | Description |
| ------------- | ------ | ----------------------------------- |
| attestationId | uint64 | The assigned ID of the attestation. |
### attest
```solidity
function attest(struct Attestation attestation, uint256 resolverFeesETH, string indexingKey, bytes delegateSignature, bytes extraData) external payable returns (uint64 attestationId)
```
Makes an attestation where the schema hook expects ETH payment.
*Emits `AttestationMade`.*
#### Parameters
| Name | Type | Description |
| ----------------- | ------------------ | --------------------------------------------------------------------------------------------------- |
| attestation | struct Attestation | See `Attestation`. |
| resolverFeesETH | uint256 | Amount of funds to send to the hook. |
| indexingKey | string | Used by the frontend to aid indexing. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated attestation. Use `""` or `0x` otherwise. |
| extraData | bytes | This is forwarded to the resolver directly. |
#### Return Values
| Name | Type | Description |
| ------------- | ------ | ----------------------------------- |
| attestationId | uint64 | The assigned ID of the attestation. |
### attest
```solidity
function attest(struct Attestation attestation, contract IERC20 resolverFeesERC20Token, uint256 resolverFeesERC20Amount, string indexingKey, bytes delegateSignature, bytes extraData) external returns (uint64 attestationId)
```
Makes an attestation where the schema hook expects ERC20 payment.
*Emits `AttestationMade`.*
#### Parameters
| Name | Type | Description |
| ----------------------- | ------------------ | --------------------------------------------------------------------------------------------------- |
| attestation | struct Attestation | See `Attestation`. |
| resolverFeesERC20Token | contract IERC20 | ERC20 token address used for payment. |
| resolverFeesERC20Amount | uint256 | Amount of funds to send to the hook. |
| indexingKey | string | Used by the frontend to aid indexing. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated attestation. Use `""` or `0x` otherwise. |
| extraData | bytes | This is forwarded to the resolver directly. |
#### Return Values
| Name | Type | Description |
| ------------- | ------ | ----------------------------------- |
| attestationId | uint64 | The assigned ID of the attestation. |
### attestOffchain
```solidity
function attestOffchain(string offchainAttestationId, address delegateAttester, bytes delegateSignature) external
```
Timestamps an off-chain data ID.
*Emits `OffchainAttestationMade`.*
#### Parameters
| Name | Type | Description |
| --------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| offchainAttestationId | string | The off-chain data ID. |
| delegateAttester | address | An optional delegated attester that authorized the caller to attest on their behalf if this is a delegated attestation. Use `address(0)` otherwise. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated attestation. Use `""` or `0x` otherwise. Use `""` or `0x` otherwise. |
### revoke
```solidity
function revoke(uint64 attestationId, string reason, bytes delegateSignature, bytes extraData) external
```
Revokes an existing revocable attestation.
*Emits `AttestationRevoked`. Must be called by the attester.*
#### Parameters
| Name | Type | Description |
| ----------------- | ------ | ---------------------------------------------------------------------- |
| attestationId | uint64 | An existing attestation ID. |
| reason | string | The revocation reason. This is only emitted as an event to save gas. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated revocation. |
| extraData | bytes | This is forwarded to the resolver directly. |
### revoke
```solidity
function revoke(uint64 attestationId, string reason, uint256 resolverFeesETH, bytes delegateSignature, bytes extraData) external payable
```
Revokes an existing revocable attestation where the schema hook expects ERC20 payment.
*Emits `AttestationRevoked`. Must be called by the attester.*
#### Parameters
| Name | Type | Description |
| ----------------- | ------- | ---------------------------------------------------------------------- |
| attestationId | uint64 | An existing attestation ID. |
| reason | string | The revocation reason. This is only emitted as an event to save gas. |
| resolverFeesETH | uint256 | Amount of funds to send to the hook. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated revocation. |
| extraData | bytes | This is forwarded to the resolver directly. |
### revoke
```solidity
function revoke(uint64 attestationId, string reason, contract IERC20 resolverFeesERC20Token, uint256 resolverFeesERC20Amount, bytes delegateSignature, bytes extraData) external
```
Revokes an existing revocable attestation where the schema hook expects ERC20 payment.
*Emits `AttestationRevoked`. Must be called by the attester.*
#### Parameters
| Name | Type | Description |
| ----------------------- | --------------- | ---------------------------------------------------------------------- |
| attestationId | uint64 | An existing attestation ID. |
| reason | string | The revocation reason. This is only emitted as an event to save gas. |
| resolverFeesERC20Token | contract IERC20 | ERC20 token address used for payment. |
| resolverFeesERC20Amount | uint256 | Amount of funds to send to the hook. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated revocation. |
| extraData | bytes | This is forwarded to the resolver directly. |
### revokeOffchain
```solidity
function revokeOffchain(string offchainAttestationId, string reason, bytes delegateSignature) external
```
Revokes an existing offchain attestation.
*Emits `OffchainAttestationRevoked`. Must be called by the attester.*
#### Parameters
| Name | Type | Description |
| --------------------- | ------ | ---------------------------------------------------------------------- |
| offchainAttestationId | string | An existing attestation ID. |
| reason | string | The revocation reason. This is only emitted as an event to save gas. |
| delegateSignature | bytes | An optional ECDSA delegateSignature if this is a delegated revocation. |
### registerBatch
```solidity
function registerBatch(struct Schema[] schemas, bytes delegateSignature) external returns (uint64[] schemaIds)
```
Batch registers a Schema.
### attestBatch
```solidity
function attestBatch(struct Attestation[] attestations, string[] indexingKeys, bytes delegateSignature, bytes extraData) external returns (uint64[] attestationIds)
```
Batch attests.
### attestBatch
```solidity
function attestBatch(struct Attestation[] attestations, uint256[] resolverFeesETH, string[] indexingKeys, bytes delegateSignature, bytes extraData) external payable returns (uint64[] attestationIds)
```
Batch attests where the schema hook expects ETH payment.
### attestBatch
```solidity
function attestBatch(struct Attestation[] attestations, contract IERC20[] resolverFeesERC20Tokens, uint256[] resolverFeesERC20Amount, string[] indexingKeys, bytes delegateSignature, bytes extraData) external returns (uint64[] attestationIds)
```
Batch attests where the schema hook expects ERC20 payment.
### attestOffchainBatch
```solidity
function attestOffchainBatch(string[] offchainAttestationIds, address delegateAttester, bytes delegateSignature) external
```
Batch timestamps off-chain data IDs.
### revokeBatch
```solidity
function revokeBatch(uint64[] attestationIds, string[] reasons, bytes delegateSignature, bytes extraData) external
```
Batch revokes revocable on-chain attestations.
### revokeBatch
```solidity
function revokeBatch(uint64[] attestationIds, string[] reasons, uint256[] resolverFeesETH, bytes delegateSignature, bytes extraData) external payable
```
Batch revokes revocable on-chain attestations where the schema hook expects ETH payment.
### revokeBatch
```solidity
function revokeBatch(uint64[] attestationIds, string[] reasons, contract IERC20[] resolverFeesERC20Tokens, uint256[] resolverFeesERC20Amount, bytes delegateSignature, bytes extraData) external
```
Batch revokes revocable on-chain attestations where the schema hook expects ERC20 payment.
### revokeOffchainBatch
```solidity
function revokeOffchainBatch(string[] offchainAttestationIds, string[] reasons, bytes delegateSignature) external
```
Batch revokes off-chain attestations.
### getSchema
```solidity
function getSchema(uint64 schemaId) external view returns (struct Schema)
```
Returns the specified `Schema`.
### getAttestation
```solidity
function getAttestation(uint64 attestationId) external view returns (struct Attestation)
```
Returns the specified `Attestation`.
### getOffchainAttestation
```solidity
function getOffchainAttestation(string offchainAttestationId) external view returns (struct OffchainAttestation)
```
Returns the specified `OffchainAttestation`.
### getDelegatedRegisterHash
```solidity
function getDelegatedRegisterHash(struct Schema schema) external pure returns (bytes32)
```
Returns the hash that will be used to authorize a delegated registration.
### getDelegatedRegisterBatchHash
```solidity
function getDelegatedRegisterBatchHash(struct Schema[] schemas) external pure returns (bytes32)
```
Returns the hash that will be used to authorize a delegated batch registration.
### getDelegatedAttestHash
```solidity
function getDelegatedAttestHash(struct Attestation attestation) external pure returns (bytes32)
```
Returns the hash that will be used to authorize a delegated attestation.
### getDelegatedAttestBatchHash
```solidity
function getDelegatedAttestBatchHash(struct Attestation[] attestations) external pure returns (bytes32)
```
Returns the hash that will be used to authorize a delegated batch attestation.
### getDelegatedOffchainAttestHash
```solidity
function getDelegatedOffchainAttestHash(string offchainAttestationId) external pure returns (bytes32)
```
Returns the hash that will be used to authorize a delegated offcha프로젝트로 돌아가기