> For the complete documentation index, see [llms.txt](https://docs.zkpass.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zkpass.org/developer-guides/js-sdk/generate-proof-and-verify-the-result/evm.md).

# EVM

### How to generate the proof with EVM?

```javascript
const generate = async (schemaId: string, appid: string) => {
    try {
      // The appid of the project created in dev center
      const appid = "8fb9d43c-2f24-424e-a98d-7ba34a5532f5"
  
      // Create the connector instance
      const connector = new TransgateConnect(appid)
  
      // Check if the TransGate extension is installed
      // If it returns false, please prompt to install it from chrome web store
      const isAvailable = await connector.isTransgateAvailable()
  
      if (isAvailable) {
        // The schema id of the project
        const schemaId = "516a720e-29a4-4307-ae7b-5aec286e446e"
  
        // Launch the process of verification
        // This method can be invoked in a loop when dealing with multiple schemas
        const res = await connector.launch(schemaId)
        
        // If you want to send the result to the blockchain, please add the wallet address as the second parameter.
        // const res = await connector.launch(schemaId, address)
  
        // verifiy the res onchain/offchain based on the requirement     
        
      } else {
        console.log('Please install TransGate')
      }
    } catch (error) {
      console.log('transgate error', error)
    }
  }
```

{% hint style="info" %}
The result includes two signatures: the allocator signature and the validator signature. Developers should verify both signatures based on the other returned fields.&#x20;
{% endhint %}

### Verify Allocator Signature

#### Encode the allocator message struct

```javascript
import Web3 from "web3"

const web3 = new Web3()

const { taskId } = res //return by Transgate

const taskIdHex = Web3.utils.stringToHex(taskId)
const schemaIdHex = Web3.utils.stringToHex(schemaId)

const encodeParams = web3.eth.abi.encodeParameters(
  ["bytes32", "bytes32", "address"],
  [taskIdHex, schemaIdHex, validatorAddress]
)
const paramsHash = Web3.utils.soliditySha3(encodeParams)
```

#### Recover the allocator address

```javascript
const signedAllocatorAddress = web3.eth.accounts.recover(paramsHash, allocatorSignature)
```

#### Check if the signed allocator address is registered. The current  allocator address is fixed.

```javascript
return signedAllocatorAddress === "0x19a567b3b212a5b35bA0E3B600FbEd5c2eE9083d"
```

### Verify Validator Signature

#### Encode the validator message

```javascript
import Web3 from "web3"

const web3 = new Web3()

const { taskId, uHash, publicFieldsHash, recipient } = res //return by Transgate

const taskIdHex = Web3.utils.stringToHex(taskId)
const schemaIdHex = Web3.utils.stringToHex(schemaId)


const types = ["bytes32", "bytes32", "bytes32", "bytes32"]
const values = [taskIdHex, schemaIdHex, uHash, publicFieldsHash]

//If you add the wallet address as the second parameter when launch the Transgate
if (recipient) {
    types.push("address")
    values.push(recipient)
}

const encodeParams = web3.eth.abi.encodeParameters(types, values)

const paramsHash = Web3.utils.soliditySha3(encodeParams)
```

#### Recover the validator address

<pre class="language-javascript"><code class="lang-javascript"><strong>const signedValidatorAddress = web3.eth.accounts.recover(paramsHash, validatorSignature)
</strong></code></pre>

#### Verify if the signed validator address matches the address assigned by the allocator

```javascript
return signedValidatorAddress === validatorAddress
```

{% hint style="info" %}
Here, we've only given the reference code for off-chain verification. However, the result can also be verified on-chain.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.zkpass.org/developer-guides/js-sdk/generate-proof-and-verify-the-result/evm.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.
