Sign 백서

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 14쪽 중 8쪽

srycgi01wfgmhv3hrf/subgraphs/sp-arbitrum-one/v1.1.0/gn> | | Celo | 42220 | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.4 | 0xAE45849165E17Dc555B8264dD4Ae01a3F42344e2 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-celo/v1.1.3/gn> | ### Legacy Mainnet Deployments These networks are no longer maintained. | Network | Address | Version | GraphQL Subgraph | | :-------------: | :----------------------------------------: | ------- | --------------------------------------------------------------------------------------------------------- | | ~~Cyber~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-cyber/v1.1.0/gn> | | ~~Degen~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-degen/v1.1.0/gn> | | ~~OKX X Layer~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-x1/v1.1.0/gn> | | ~~Scroll~~ | 0xFBF614E89Ac79d738BaeF81CE6929897594b7E69 | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-scroll/v1.1.0/gn> | | ~~ZetaChain~~ | 0xBbc279ee396074aC968b459d542DEE60c6bD71C1 | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-zetachain/v1.1.0/gn> | | ~~ZetaChain~~ | 0x1BC26dd23b773806f080Acf65Cfb744166be9463 | 1.0.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-zetachain/v1.0.0/gn> | ## Testnet *Testnet deployments are NOT production ready and subject to change without notice.* | Network | Chain ID | Proxy | Version | Owner | GraphQL Subgraph | | :-----: | -------: | :----------------------------------------: | ------- | :----------------------------------------: | ------------------------------------------------------------------------------------------------------- | | Sepolia | 11155111 | 0x878c92FD89d8E0B93Dc0a3c907A2adc7577e39c5 | 1.1.4 | 0xAE45849165E17Dc555B8264dD4Ae01a3F42344e2 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-sepolia/v1.1.0/gn> | ### Legacy Testnet Deployments These networks are no longer maintained. | Network | Address | Version | GraphQL Subgraph | | :------------------: | :----------------------------------------: | ------- | ----------------------------------------------------------------------------------------------------------------- | | ~~Arbitrum Sepolia~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-arbitrum-sepolia/v1.1.0/gn> | | ~~Base Sepolia~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-base-sepolia/v1.1.0/gn> | | ~~Berachain Artio~~ | 0x2774d96a841E522549CE7ADd3825fC31075384Cf | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-berachain-testnet/v1.1.0/gn> | | ~~Celo Alfajores~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.3 | <https://api.studio.thegraph.com/query/49892/sp-celo-alfajores/version/latest> | | ~~Gnosis Chiado~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-gnosis-chiado/v1.1.0/gn> | | ~~opBNB~~ | 0x72efA4093539A909C1f9bcCA1aE6bcDa435a3433 | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-opbnb-testnet/v1.1.0/gn> | | ~~Optimism Sepolia~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-op-sepolia/v1.1.0/gn> | | ~~Plume~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-plume-sepolia/v1.1.0/gn> | | ~~Polygon Amoy~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-amoy/v1.1.0/gn> | | ~~Polygon Mumbai~~ | 0x4665fffdD8b48aDF5bab3621F835C831f0ee36D7 | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-mumbai-testnet/v1.1.0/gn> | | ~~Scroll Sepolia~~ | 0x4e4af2a21ebf62850fD99Eb6253E1eFBb56098cD | 1.1.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-scroll-sepolia/v1.1.0/gn> | | ~~ZetaChain Athens~~ | 0x00aFD4466E4Afa4F43cCd414b1BC65e574ACA2f5 | 1.0.1 | <https://api.goldsky.com/api/public/project\\_cls8h0isrycgi01wfgmhv3hrf/subgraphs/sp-zetachain-testnet/v1.0.0/gn> | # Sign Developer Platform [Sign Developer Platform](https://developer.sign.global), or SDP, gives developers API access to various Sign Protocol services, such as paying for decentralized data storage. ### General Usage Visit [Sign Developer Platform](https://developer.sign.global) and create an API key with the appropriate scopes. To fund the account balance to pay for API key usage, you can purchase credits with USDC (1 USDC = 100 Credits). Once the account is properly funded, you can call the following API endpoints: * Testnet: <https://testnet-rpc.sign.global/api> * Mainnet: <https://mainnet-rpc.sign.global/api> Make sure the proper header is attached in your API request: ``` Headers = { 'x-sign-api-key': 'API key' } ``` Alternatively, you can use our [SDK](https://www.npmjs.com/package/@ethsign/sp-sdk) (>= 0.9.7) which has been updated to work with API keys. ### Uploading Data to Decentralized Storage To upload data to decentralized storage, use the following URL: `POST {endpoint}/sp/offchain-storage` and request: ```json { "storageType": 'arweave' | 'ipfs' | 'greenfield', "data": "your data" } ``` The appropriate amount of fees will be deducted from the account. The total amount of fees paid is the sum of the base fee and size fee. | Platform | Base Fee | Size Fee (per byte) | | -------------- | -------- | ------------------- | | Arweave | 0.01 | 0.0000000006 | | BNB Greenfield | 0.01 | 0.00000000004 | | IPFS | 0.01 | 0.000000000002 | *Please note the above fees may be adjusted without notice. All fee units are in Credits.* # Advanced Topics # Cross Chain Attestations Ever since the dawn of blockchain systems, developers and users alike have faced the dilemma of data storage and availability, where data stored on one blockchain is completely inaccessible from another blockchain. Sign Protocol faces a similar challenge, where attested data simply isn’t available across different blockchains, even if they share a common key derivation algorithm. **At the very least, data that’s digitally signed and attested on Base should be just as valid on BNB Chain, for example.** There are plenty of existing mature cross-chain solutions, such as Chainlink CCIP and LayerZero, but none of them satisfy the flexibility that Sign Protocol requires (e.g. pulling and validating data from atypical blockchains such as Arweave). As such, we have partnered with [Lit Protocol](https://www.litprotocol.com/) to present a TEE-based cross-chain attestation verification solution. ### What is a TEE? A Trusted Execution Environment (TEE) is a secure part of a device's main processor that provides a protected space for sensitive operations. It ensures that sensitive data and code are stored, processed, and executed in a way that is isolated from the rest of the system, including the main operating system and applications. This isolation helps prevent unauthorized access or tampering, even if the primary system is compromised. The TEE operates alongside the main environment but remains insulated from potential vulnerabilities or threats present in the general computing environment. It allows only trusted applications to execute within this secure space, ensuring the confidentiality and integrity of operations like cryptographic computations or secure key management. TEEs are commonly used in scenarios requiring high security, such as mobile payments, digital rights management, and authentication services. Examples of TEEs include ARM's TrustZone, Intel's SGX, and AMD's ASP, which powers Lit Protocol's decentralized hardware TEE offering. Sign Protocol uses decentralized TEE to ensure the integrity of cross-chain attestation data and each cross-chain verification result is attached with a digital signature signed by at least 2/3 of the entire Lit network using threshold cryptography to prove consensus. You can read more about it [here](https://developer.litprotocol.com/resources/how-it-works). ### Workflow 1. The requester makes an attestation on an official cross-chain schema created by Sign. The attestation contains the target chain ID, target attestation ID, and encoded data to verify, all of which is encoded in `extraData` for gas efficiency (since `extraData` is only passed to the hook and emitted as an event instead of being stored, which makes it \~95% cheaper). 1. We also support navigating a JSON path to make it possible to verify a particular field within a piece of large sized JSON data on Arweave. 2. The schema hook charges a fee to cover the cross-chain verification cost and emits a special event that makes `extraData` available for the Lit nodes. 3. Lit Action is triggered by this event. 4. Lit Action independently: 1. Fetches the event and decodes `extraData`. 2. Fetches the target attestation on the target chain. 3. Compares target attestation data against decoded data. 4. Returns a signed (with Lit key) delegated attestation signature based on the official cross-chain response schema that includes the comparison result boolean. 5. Sign Protocol makes the delegated attestation on behalf of the Lit nodes. 6. The cross-chain verification process is now complete. ### Roadmap Cross-chain attestations will be available in Q1 2025. Stay tuned! # Hybrid Attestations Hybrid attestations are standard on-chain attestations that store data separate from the current blockchain network. For example, a hybrid attestation may store its data on Arweave or IPFS instead of directly within a Sign Protocol smart contract, where the metadata and schema information are stored. With hybrid attestations, the attestation data is uploaded to Arweave/IPFS, and the resulting CID is encoded and stored in the `data` field of the attestation on-chain. This can be useful when the attestation data is expected to be sufficiently large that gas fees would be exceptionally high or when easy data access is required from front-end clients. Projects can cache CIDs for quick data retrieval instead of querying, fetching, and decoding data every time an attestation is retrieved. <figure><img src="https://3152654701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw182g9YzR34mTxEBTKXX%2Fuploads%2Fgit-blob-fa71fed8d8145ece98c222f226d4d3bcbc3d6cd2%2Fhybrid-attestation-model.svg?alt=media" alt=""><figcaption><p>Hybrid Attestation Model</p></figcaption></figure> Sign Protocol's [SDK](/for-builders/index-1/npm-sdk/installation) allows direct interaction with hybrid attestations, and the [Schema Builder](https://app.sign.global/create-schema) enables users to easily build hybrid schemas by choosing an on-chain schema with a data storage location of Arweave or IPFS. ### Smart Contract Interaction with Hybrid Attestations #### Steps 1. Upload the attestation's data to the storage location (Arweave/IPFS) in JSON format. 2. Encode the returned Content ID (CID). 3. Create an attestation, passing in the encoded CID as `data`. # Schema Hooks To run custom Solidity code when an attestation is created or revoked, you will need to use a Schema Hook. Schema hooks enable schema creators to add whitelists, take payments, and write any custom application logic which will be called from Sign Protocol's smart contract. Any reverts in the schema hook will revert the entire call, allowing schema builders to control attestation creation and revocation logic. ## Interface Schema hooks must conform to the ISPHook interface, which can be found [here](/for-builders/index-1/index/index/index/isphook). ## Example The following example implements a basic whitelist schema hook. The owner of the `WhitelistManager` contract can add or remove user addresses on the whitelist. The `WhitelistHook` contract will be called when attestations are created and revoked. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; import { ISPHook } from "@ethsign/sign-protocol-evm/src/interfaces/ISPHook.sol"; // @dev This contract manages the whitelist. We are separating the whitelist logic from the hook to make things easier // to read. contract WhitelistMananger is Ownable { mapping(address attester => bool allowed) public whitelist; error UnauthorizedAttester(); constructor() Ownable(_msgSender()) { } function setWhitelist(address attester, bool allowed) external onlyOwner { whitelist[attester] = allowed; } function _checkAttesterWhitelistStatus(address attester) internal view { // solhint-disable-next-line custom-errors require(whitelist[attester], UnauthorizedAttester()); } } // @dev This contract implements the actual schema hook. contract WhitelistHook is ISPHook, WhitelistMananger { function didReceiveAttestation( address attester, uint64, // schemaId uint64, // attestationId bytes calldata // extraData ) external payable { _checkAttesterWhitelistStatus(attester); } function didReceiveAttestation( address attester, uint64, // schemaId uint64, // attestationId IERC20, // resolverFeeERC20Token uint256, // resolverFeeERC20Amount bytes calldata // extraData ) external view { _checkAttesterWhitelistStatus(attester); } function didReceiveRevocation( address attester, uint64, // schemaId uint64, // attestationId bytes calldata // extraData ) external payable { _checkAttesterWhitelistStatus(attester); } function didReceiveRevocation( address attester, uint64, // schemaId uint64, // attestationId IERC20, // resolverFeeERC20Token uint256, // resolverFeeERC20Amount bytes calldata // extraData ) external view { _checkAttesterWhitelistStatus(attester); } } ``` # Tutorial: Checking Attestation Data In this tutorial, we will create a schema hook that checks an attestation's `data` variable. A threshold value must be met for the attestation to be created. When you are ready to begin, please navigate to the next page. # Schema Creation To limit which attestations are created, we want to check the supplied attestation data using a custom schema hook. If our hook's code reverts, the attestation will not be created. If the attestation data meets our requirements, the hook will allow the attestation to be created. First, we need to define our schema data. For this tutorial, the schema data will only include a number. Our schema looks like the following: ```json [ { "name": "threshold", "type": "uint256" } ] ``` Your schema hook's address must be supplied when you create a schema. Now that you know what the schema's data looks like, let's build our schema hook. # Schema Hook A schema hook contract is a regular solidity smart contract that inherits from the [ISPHook](/for-builders/index-1/index/index/index/isphook) interface and implements all required functions. You can implement the ISPHook interface on any contract, allowing you to merge Sign Protocol schema callbacks with your application's smart contract logic. For clarity in this tutorial, we will separate our schema hook contract from the contract containing validation logic. ### Validation Logic Our schema hook is responsible for ensuring attestation data contains a number above a certain threshold. If this condition is met (the threshold value in the attestation data is large enough), the attestation will be successfully created. Otherwise, we will revert the transaction and the attestation will fail to be created. For our validator contract, we need to create two functions: `setThreshold` and `_checkThreshold`. The threshold specified in `setThreshold` will determine which attestations are allowed to be created. We will enforce this by calling `_checkThreshold` in our schema hook contract. ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; // @dev This contract manages attestation data validation logic. contract DataValidator is Ownable { uint256 public threshold; error NumberBelowThreshold(); constructor() Ownable(_msgSender()) { } function setThreshold(uint256 threshold_) external onlyOwner { threshold = threshold_; } function _checkThreshold(uint256 number) internal view { // solhint-disable-next-line custom-errors require(number >= threshold, NumberBelowThreshold()); } } ``` ### Schema Hook Implementation When an attestation is received, the schema hook's logic is pretty simple: we need to read the attestation data to extract the threshold value we are trying to validate, and then we need to validate it. #### Reading Attestation Data To get the attestation data, we need to read the attestation object from Sign Protocol's contract. You can find all available Sign Protocol smart contract functions [here](/for-builders/index-1/index/index/index/isp). Remember that your schema hook is being called from the Sign Protocol smart contract, so you can use `_msgSender()` to get the appropriate smart contract address that you need to call. ```solidity import { Attestation } from "@ethsign/sign-protocol-evm/src/models/Attestation.sol"; ... Attestation memory attestation = ISP(_msgSender()).getAttestation(attestationId); ``` #### Decoding Attestation Data The attestation object you retrieved in the last step will have `data` encoded according to your schema's data format. In our case, the schema we created contains only a `uint256`. We can use `abi.decode` to decode the attestation data into the correct format. ```solidity abi.decode(attestation.data, (uint256)); ``` You can now use this decoded data to call `_checkThreshold`. If your schema has additional variables in its data field, these will be decoded similarly. For example, take the following schema data format: <pre class="language-json"><code class="lang-json">[ <strong> { </strong> "name": "name", "type": "string" <strong> }, </strong> { "name": "timestamp", "type": "uint256" }, { "name": "hash", "type": "bytes32" } ] </code></pre> An attestation's data following the above data format can be decoded in Solidity using the following: ```solidity (string memory name, uint256 timestamp, bytes32 hash) = abi.decode(attestation.data, (string, uint256, bytes32)); ``` ### Bringing It All Together For this tutorial, we will only implement `didReceiveAttestation`, but the process is the same for the other functions in ISPHook. In our case, we did not check the `attester`, nor did we use the `schemaId` or `extraData`. {% hint style="info" %} `extraData` is not the same as your attestation's data - this parameter provides a way for you to send additional information to your schema hook when an attestation is being created or revoked. `extraData` is not stored onchain with the attestation itself. It is only used in the schema hook. {% endhint %} ```solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; import { ISP } from "@ethsign/sign-protocol-evm/src/interfaces/ISP.sol"; import { ISPHook } from "@ethsign/sign-protocol-evm/src/interfaces/ISPHook.sol"; import { A
프로젝트로 돌아가기