EAS Library Documentation
Intro
The following documents the method to work with EAS attestations via Ethereum Account Abstraction.
Methods
generate12Words
Generates 12 words phrase (BIP39) for wallet creation.
static generateMnemonic(): string[]
derivePrivateKeyFrom12Words
Derives the private key from the 12-word mnemonic.
static getPrivateKeyFromMnemonic(mnemonic: string[]): string
derivePublicKeyAndAddress
Derives the Ethereum address from the provided private key.
static getAddressFromPrivateKey(privateKey: string): string
loadEASSchema
Load the EAS schema to an address.
static async loadEASSchema(schema: string): Promise<void>
createAbstractAccount
Creates an abstract account for the wallet using the provided address. Throws an error on fail.
static async createAbstractAccount(address: string): Promise<void>
prepareEASTx
Prepares an EAS transaction by signing it with the provided private key.
static prepareEASTx(data: any, privateKey: string): string
prepareEASBatchTx
Prepares a batch of EAS transactions by signing each transaction in the batch.
static prepareEASBatchTx(dataArray: any[], privateKey: string): string
sendEASTx
Sends the transaction to the network.
static async sendEASTx(signedTx: string): Promise<string>
getEASExplorerLink
Returns the EAS explorer link for the given UID.
static getEASExplorerLink(uid: string): string
Example Usage
async function main() {
const mnemonic: string[] = WalletLibrary.generate12Words()
const privateKey: string = WalletLibrary.derivePrivateKeyFrom12Words(mnemonic)
const keyInfo = WalletLibrary.derivePublicKeyAndAddress(privateKey)
const address: string = keyInfo.address
await WalletLibrary.createAbstractAccount(address)
const easTransaction: string = WalletLibrary.prepareEASTx({ data: 'sample' }, privateKey)
const easBatchTransaction: string = WalletLibrary.prepareEASBatchTx(
[{ data: 'sample1' }, { data: 'sample2' }],
privateKey
)
const explorerLink: string = WalletLibrary.getEASExplorerLink('uid123')
}
Other Considerations
- A script to create attestation scheme on-chain