# EVM网络

该文档描述了TokenPocket钱包在EVM网络下的相关二维码协议。TokenPocket Android版本从1.6.7开始支持本协议，EVM网络观察钱包冷钱包交互使用该协议，新版本的应用兼容老版本协议。

### 签名交易

<pre><code>//
ethereum:signTransaction-version=1.0&#x26;protocol=TokenPocket&#x26;network=ethereum
&#x26;chain_id=1&#x26;data=
    {
    	"from": "xxx",
    	"gas": "0x5208",
    	"chainId": 1,
    	"to": "xxx",
    	"value": "0x38d7ea4c68000",
    	"type": "0x2",
    	"maxFeePerGas": "0x11853fe080",
    	"maxPriorityFeePerGas": "0x4a817c80",
    	"nonce": "0x0"
    }


ethereum:signTransaction //标识操作类型
network //该操作支持的网络
chain_id //网络id
data //交易数据

<strong>//签名交易结果
</strong>ethereum:signTransactionSignature-version=1.0&#x26;protocol=TokenPocket&#x26;network=ethereum&#x26;chain_id=1&#x26;data={
	"rawTransaction":"xxxx"
 }
 
</code></pre>

### 签名并发送交易

```
//
ethereum:signAndSendTransaction-version=1.0&protocol=TokenPocket&network=ethereum
&chain_id=1&data=
    {
    	"from": "xxx",
    	"gas": "0x5208",
    	"chainId": 1,
    	"to": "xxx",
    	"value": "0x38d7ea4c68000",
    	"type": "0x2",
    	"maxFeePerGas": "0x11853fe080",
    	"maxPriorityFeePerGas": "0x4a817c80",
    	"nonce": "0x0"
    }
```

### ethPersonalSign签名

```
//
 ethereum:personalSign-version=1.0&protocol=TokenPocket&network=ethereum&chain_id=1&data={
	"message":"abcdeea",
	"address":"xxx" //可选，如果填写了地址，钱包会去找指定地址签名
 }
 ethereum:personalSignSignature-version=1.0&protocol=TokenPocket&network=ethereum&chain_id=1&data={
	"signature":"xxx", //签名结果
	"address":"xxx" //签名地址
 }

```

### ethSignTypedDataLegacy签名

```
//
 ethereum:signTypedDataLegacy-version=1.0&protocol=TokenPocket&network=ethereum&chain_id=1&data={
	"message": [{
		"type": "string",
		"name": "Message",
		"value": "Hi, Alice!"
	}, {
		"type": "uint32",
		"name": "A number",
		"value": "1337"
	}],
	"address":"xxx" //可选，如果填写了地址，钱包会去找指定地址签名
 }
 ethereum:signTypedDataLegacySignature-version=1.0&protocol=TokenPocket&network=ethereum&chain_id=1&data={
	"signature":"xxx", //签名结果
	"address":"xxx" //签名地址
 }
```

### ethSignTypedData

```
//
ethereum:signTypeData-version=1&protocol=TokenPocket&network=ethereum&chain_id=1&data={
          "message":{"types": {
		"EIP712Domain": [{
			"name": "name",
			"type": "string"
		}, {
			"name": "version",
			"type": "string"
		}, {
			"name": "chainId",
			"type": "uint256"
		}, {
			"name": "verifyingContract",
			"type": "address"
		}],
		"Person": [{
			"name": "name",
			"type": "string"
		}, {
			"name": "wallet",
			"type": "address"
		}],
		"Mail": [{
			"name": "from",
			"type": "Person"
		}, {
			"name": "to",
			"type": "Person"
		}, {
			"name": "contents",
			"type": "string"
		}]
	},
	"primaryType": "Mail",
	"domain": {
		"name": "Ether Mail",
		"version": "1",
		"chainId": 1,
		"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
	},
	"message": {
		"sender": {
			"name": "Cow",
			"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
		},
		"recipient": {
			"name": "Bob",
			"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
		},
		"contents": "Hello, Bob!"
	}
	},
	"address":"xxx"
}

//签名结果
 ethereum:signTypeDataSignature-version=1.0&protocol=TokenPocket&network=ethereum&chain_id=1&data={
	"signature":"xxx", //签名结果
	"address":"xxx" //签名地址
 }
```

### ethSignTypedData\_V4

```
// 
 ethereum:signTypeDataV4-version=1.0&protocol=TokenPocket&network=ethereum&chain_id=1&data={
	"message":{
	  "domain": {
		"chainId": 1,
		"name": "EtherMail",
		"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
		"version": "1"
	 },
	  "message": {
		"contents": "Hello,Bob!",
		"from": {
			"name": "Cow",
			"wallets": ["0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", "0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF"]
		},
		"to": [{
			"name": "Bob",
			"wallets": ["0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB", "0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57", "0xB0B0b0b0b0b0B000000000000000000000000000"]
		}]
	},
	"primaryType": "Mail",
	"types": {
		"EIP712Domain": [{
			"name": "name",
			"type": "string"
		}, {
			"name": "version",
			"type": "string"
		}, {
			"name": "chainId",
			"type": "uint256"
		}, {
			"name": "verifyingContract",
			"type": "address"
		}],
		"Group": [{
			"name": "name",
			"type": "string"
		}, {
			"name": "members",
			"type": "Person[]"
		}],
		"Mail": [{
			"name": "from",
			"type": "Person"
		}, {
			"name": "to",
			"type": "Person[]"
		}, {
			"name": "contents",
			"type": "string"
		}],
		"Person": [{
			"name": "name",
			"type": "string"
		}, {
			"name": "wallets",
			"type": "address[]"
		}]
		}
	},
	"address":"xxx" //可选，如果填写了地址，钱包会去找指定地址签名
 }
 ethereum:signTypeDataV4Signature-version=1.0&protocol=TokenPocket&network=ethereum&chain_id=1&data={
	"signature":"xxx", //签名结果
	"address":"xxx" //签名地址
 }
```

### 参考文档

<https://github.com/ethereum/EIPs/blob/9e393a79d9937f579acbdcb234a67869259d5a96/EIPS/eip-681.md>


---

# 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://help.tokenpocket.pro/developer-cn/scan-protocol/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.
