Разработка системы атестации (EAS — Ethereum Attestation Service)
EAS (Ethereum Attestation Service) — открытый протокол для создания on-chain и off-chain attestations (подтверждений) на Ethereum и L2. Attestation — это любое заявление от одного адреса о другом адресе или факте. «Адрес A подтверждает что адрес B прошёл KYC», «Адрес A подтверждает что B является участником DAO».
Ключевые концепции EAS
Schema: структура данных attestation. Зарегистрирована on-chain в SchemaRegistry. Определяет поля и их типы.
Attestation: конкретное подтверждение по схеме. Содержит данные, attester (кто подтвердил), recipient (о ком), expiration, revocable флаг.
On-chain vs Off-chain: attestations могут храниться on-chain (дорого, но постоянно) или off-chain (IPFS/Arweave) с on-chain UID для верификации.
Регистрация схемы
import { ISchemaRegistry, SchemaRecord } from "@ethereum-attestation-service/eas-contracts/contracts/ISchemaRegistry.sol";
ISchemaRegistry schemaRegistry = ISchemaRegistry(EAS_SCHEMA_REGISTRY);
// Регистрация схемы
bytes32 schemaUID = schemaRegistry.register(
"bool isKYCVerified, uint8 verificationLevel, string jurisdiction",
ISchemaResolver(resolverAddress), // опциональный resolver контракт
true // revocable
);
Создание Attestation
import { IEAS, AttestationRequest, AttestationRequestData } from "@ethereum-attestation-service/eas-contracts/contracts/IEAS.sol";
IEAS eas = IEAS(EAS_ADDRESS);
bytes32 attestationUID = eas.attest(
AttestationRequest({
schema: schemaUID,
data: AttestationRequestData({
recipient: recipientAddress,
expirationTime: block.timestamp + 365 days,
revocable: true,
refUID: bytes32(0),
data: abi.encode(true, 2, "EU"), // isKYCVerified, level, jurisdiction
value: 0
})
})
);
Schema Resolver
Опциональный смарт-контракт который вызывается при создании/отзыве attestation — для дополнительной логики:
import { SchemaResolver } from "@ethereum-attestation-service/eas-contracts/contracts/resolver/SchemaResolver.sol";
contract KYCAttestationResolver is SchemaResolver {
mapping(address => bool) public verifiedAddresses;
function onAttest(Attestation calldata attestation, uint256)
internal override returns (bool) {
// Только whitelist attesters могут создавать
require(authorizedAttesters[attestation.attester], "Not authorized");
(, uint8 level,) = abi.decode(attestation.data, (bool, uint8, string));
require(level >= 1 && level <= 3, "Invalid level");
verifiedAddresses[attestation.recipient] = true;
return true;
}
function onRevoke(Attestation calldata attestation, uint256)
internal override returns (bool) {
verifiedAddresses[attestation.recipient] = false;
return true;
}
}
EAS SDK (TypeScript)
import { EAS, SchemaEncoder } from "@ethereum-attestation-service/eas-sdk";
const eas = new EAS(EAS_ADDRESS);
eas.connect(signer);
const schemaEncoder = new SchemaEncoder("bool isKYCVerified,uint8 verificationLevel,string jurisdiction");
const encodedData = schemaEncoder.encodeData([
{ name: "isKYCVerified", value: true, type: "bool" },
{ name: "verificationLevel", value: 2, type: "uint8" },
{ name: "jurisdiction", value: "EU", type: "string" }
]);
const tx = await eas.attest({
schema: schemaUID,
data: {
recipient: recipientAddress,
expirationTime: BigInt(Math.floor(Date.now() / 1000) + 365 * 24 * 3600),
revocable: true,
data: encodedData
}
});
const uid = await tx.wait();
Use cases
EAS используется в: Gitcoin Passport (attestations об on-chain активности), Optimism Retro Funding (attestations об contribution), Safe (attestations о доверенных адресах).
Разработка системы на основе EAS — 2-4 недели для custom schema + resolver + frontend.







