# Attestation Creation

Great! We now have a schema ready for use. We will refer to this schema throughout the remainder of the project by its ID, so save the ID of the schema you created. If you bypassed the previous step, you can use [this schema](https://testnet-scan.sign.global/schema/onchain_evm_84532_0x34) to continue through this tutorial (Schema ID: `onchain_evm_84532_0x34`). Note that the on-chain ID of the schema is `0x34` and we will use this when creating an attestation.

## Creating an Attestation

You can create an attestation using either our NPM SDK or by directly interacting with the respective Smart Contract for the specific network you are using.&#x20;

### Smart Contract Interaction

{% hint style="warning" %}
NOTE: If you selected a data storage option that is not directly on-chain (such as Arweave/IPFS), your schema will require [Hybrid Attestations](/for-builders/advanced-topics/hybrid-attestations.md). Our SDK will handle this for you, but if you are interacting directly with Sign Protocol smart contracts, ensure that you are passing in an encoded Content ID (CID) as `data` when creating a hybrid attestation.
{% endhint %}

Let's write a function that takes in a contract's message string and the address of the person who signed it. You can get the Contract Address in the [Address Book](/for-builders/address-book.md) and the latest ABI on Etherscan.

```typescript
import { Web3Provider } from "@ethersproject/providers";
import { BigNumber, Contract, ethers } from "ethers";

function createNotaryAttestation(contractDetails: string, signer: string) {
  let address = "0x..."; // Alice's address. Will need Alice's account to send the tx.
  let schemaData = ethers.utils.defaultAbiCoder.encode(
    ["string", "address"],
    [contractDetails, signer]
  );
  
  // Standard setup for the contract
  const provider = new ethers.providers.JsonRpcProvider(
    // Get an RPC URL (such as an infura link) to connect to the network
    getProviderUrl(84532)
  );
  // Get the contract address from the Address Book in docs.sign.global
  const contract = new Contract(CONTRACT_ADDRESS(84532), ISPABI.abi, provider);
  // Get the provider from the currently connected wallet
  const library = new Web3Provider(await connector.getProvider());
  // Create writable contract instance
  const instance = contract.connect(library.getSigner() as any) as Contract;
  
  // Send the attestation transaction
  try {
    await instance[
      "attest((uint64,uint64,uint64,uint64,address,uint64,uint8,bool,bytes[],bytes),string,bytes,bytes)"
    ](
      {
        schemaId: BigNumber.from("0x34"), // The final number from our schema's ID.
        linkedAttestationId: 0, // We are not linking an attestation.
        attestTimestamp: 0, // Will be generated for us.
        revokeTimestamp: 0, // Attestation is not revoked.
        attester: address, // Alice's address.
        validUntil: 0, // We are not setting an expiry date.
        dataLocation: 0, // We are placing data on-chain.
        revoked: false, // The attestation is not revoked.
        recipients: [signer], // Bob is our recipient.
        data: schemaData // The encoded schema data.
      },
      signer.toLowerCase(), // Bob's lowercase address will be our indexing key.
      "0x", // No delegate signature.
      "0x00" // No extra data.
    )
      .then(
        async (tx: any) =>
          await tx.wait(1).then((res) => {
            console.log("success", res);
            // You can find the attestation's ID using the following path:
            // res.events[0].args.attestationId
          })
      )
      .catch((err: any) => {
        console.log(err?.message ? err.message : err);
      });
  } catch (err: any) {
    console.log(err?.message ? err.message : err);
  }
}
```

### NPM SDK

The SDK simplifies the process rather than directly interacting with the smart contract. To perform the same action as above, we will do the following:

```typescript
function createNotaryAttestation(contractDetails: string, signer: string) {
  const res = await client.createAttestation({
    schemaId: "0x34",
    data: {
      contractDetails,
      signer
    },
    indexingValue: signer.toLowerCase()
  });
}
```

Note that we can pass in all the attestation information like we did when sending the transaction directly to the smart contract, but we do not need to. The SDK will fill in the blank fields with their respective defaults. `createAttestation` will return data in the following format:

```json
{
  attestationId: '0x..',
  txHash: '0x..',
  indexingValue: '...'
}
```

Now that you have successfully created an attestation, you need to be able to use it! When you're ready, move on to the next page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sign.global/for-builders/getting-started/tutorials/building-a-simple-notary-platform/attestation-creation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
