# EVM Engine API
### Create Account
```bash
POST /api/evm/account
```
#### Parameters
| Name | Type | Default | Description |
| --------- | ------ | ------- | ------------------------------------------- |
| password | string | password | **Optional.** Password of the account. |
| value | number | 0 | **Optional.** Initial value of the account. |
#### Sample Input
```
{
"password": "password",
"initialValue":100000
}
```
#### Sample Response
```
{
"address": "0x659942e98ba4a88bab4de115f5e8361db4125150",
"keystore": {
"version": 3,
"id": "a9725dd2-8f70-4fb9-807c-35ac9c8e8974",
"address": "659942e98ba4a88bab4de115f5e8361db4125150",
"crypto": {
"ciphertext": "d49fb9adcb5d772dcdc2c22ae0ce3c13d07158f87b6e2e3fbebd5038c589ae07",
"cipherparams": {
"iv": "6808f89bd5133744beadf8fee27238a6"
},
"cipher": "aes-128-ctr",
"kdf": "scrypt",
"kdfparams": {
"dklen": 32,
"salt": "f432abaef2158b69f3fb12ec28924146bd6126549e494625a23a5cab6936c82e",
"n": 8192,
"r": 8,
"p": 1
},
"mac": "ac78c1d7cad0273292613fdc934aea34a63d588687dc2457418d6f09807797aa"
}
}
}
```
---
### Fetch Account
```bash
GET /api/evm/account/:address
```
#### Sample Query
```
GET /api/evm/account/0x659942e98Ba4a88Bab4DE115f5E8361DB4125150
```
#### Sample Response
```
{
"address": "0x659942e98Ba4a88Bab4DE115f5E8361DB4125150",
"balance": 100000,
"nonce": 0
}
```
---
### Transfer
```bash
POST /api/evm/transfer
```
#### Parameters
| Name | Type | Description |
| -------- | ------ | ------------------------------------------------------------------------------- |
| address | string | Address of the sender. |
| password | string | Password of the sender account, it will be used for decrpyting the `keystore`. |
| keystore | JSON | Key store of the sender account. |
| value | number | Value of currency that will be tranfer from sender account to receiver account. |
#### Sample Input
```
{
"keystore":{
"version": 3,
"id": "a9725dd2-8f70-4fb9-807c-35ac9c8e8974",
"address": "659942e98ba4a88bab4de115f5e8361db4125150",
"crypto": {
"ciphertext": "d49fb9adcb5d772dcdc2c22ae0ce3c13d07158f87b6e2e3fbebd5038c589ae07",
"cipherparams": {
"iv": "6808f89bd5133744beadf8fee27238a6"
},
"cipher": "aes-128-ctr",
"kdf": "scrypt",
"kdfparams": {
"dklen": 32,
"salt": "f432abaef2158b69f3fb12ec28924146bd6126549e494625a23a5cab6936c82e",
"n": 8192,
"r": 8,
"p": 1
},
"mac": "ac78c1d7cad0273292613fdc934aea34a63d588687dc2457418d6f09807797aa"
}
},
"password":"password",
"value":"100",
"address":"0xc2234d119795de9dc9ae2b0a92e729d09c944083"
}
```
#### Sample Response
```
{
"host": "node9.puyuma.org",
"port": 8080,
"tx": {
"from": {
"value": "0xc2234d119795de9dc9ae2b0a92e729d09c944083"
},
"to": {
"value": "0xc2234d119795de9dc9ae2b0a92e729d09c944083"
},
"value": "100",
"gas": 1000000,
"gasPrice": 0,
"nonce": 0,
"chainId": 1
},
"constant": false,
"signedTX": {
"messageHash": "0x52ba73c35433d3ba4eb52ae5668b37ff599c48f9f7efd7de05d73f68b1e8b2a4",
"v": "0x25",
"r": "0x890acc6a65c46b98d76941342ee3c1ff05178fe5dad60be33a253dafe72bc29c",
"s": "0x549dfb66450049d2455bbe0e75a2bbf91f6472140aa7c025a2d089a6773c59c2",
"rawTransaction": "0xf8608080830f424094c2234d119795de9dc9ae2b0a92e729d09c944083648025a0890acc6a65c46b98d76941342ee3c1ff05178fe5dad60be33a253dafe72bc29ca0549dfb66450049d2455bbe0e75a2bbf91f6472140aa7c025a2d089a6773c59c2"
},
"hash": "0x912e45199d6136825f98b89bca6f4b22933721bd4163cfdf5922fde8b73b1e1c"
}
```
---
### Deploy Contract
```bash
POST /api/evm/contract
```
#### Parameters
| Name | Type | Description |
| -------- | ------ | ------------------------------------------- |
| keystore | string | Key store of the contract owner. |
| password | string | Password of the contract owner. |
| contract | string | A contract is written in Solidity language. |
| name | string | Contract name. |
| version | string | Solc version. |
#### Sample Input
```
{
"keystore": {"version":3,"id":"35deb6d1-67b7-4de8-9379-ed0e7f515923","address":"c772123056a6eeafbe4bc0d9a2963a7181682553","crypto":{"ciphertext":"f41576c0a1b38a8c34c48d6537d22deccfe4c8803d6123d037e57564841cd6a7","cipherparams":{"iv":"6e1e1746d6eba043d25d2b8c0cc3c4c8"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"b2515c4fce6c92271ae9b61f1411f663fead06b2cf5074b20413700086af07e5","n":8192,"r":8,"p":1},"mac":"e374cccee0d8990610d30ce1a69e3a3a814f74d02aafec4fd7107941f7d53b33"}},
"password": "password",
"contract": "pragma solidity ^0.4.24; contract claimHub { mapping(string => Claim) claims; struct Claim{ string owner; string claimContent; } function setClaim(string _owner, string _claimContent) public { claims[_owner].owner = _owner; claims[_owner].claimContent = _claimContent; } function getClaim(string _owner) public view returns (string) { return claims[_owner].claimContent; }}",
"contractName": "claimHub",
"solcVersion": "v0.4.25+commit.59dbf8f1"
}
```
#### Sample Response
```
{
"address": "0x1c5d5a2298ee5e71c69debba12e13721f4da6093",
"abi": [
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "string"
}
],
"name": "getClaim",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_owner",
"type": "string"
},
{
"name": "_claimContent",
"type": "string"
}
],
"name": "setClaim",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]
}
```
---
### Interact with Contract
```bash
POST /api/evm/contract
```
#### Parameters
| Name | Type | Description |
| ----------- | ------ | ---------------------------------------------------------------- |
| address | string | Address of the deployed contract |
| keystore | JSON | Key store of the user. |
| password | string | Password of the user. |
| contract | string | A contract written in Solidity language. |
| method | string | Method name of the smart contract. |
| parameters | Array | Parameters of the method that will be used for method arguments. |
#### Sample Input
```
{
"keystore": {"version":3,"id":"35deb6d1-67b7-4de8-9379-ed0e7f515923","address":"c772123056a6eeafbe4bc0d9a2963a7181682553","crypto":{"ciphertext":"f41576c0a1b38a8c34c48d6537d22deccfe4c8803d6123d037e57564841cd6a7","cipherparams":{"iv":"6e1e1746d6eba043d25d2b8c0cc3c4c8"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"b2515c4fce6c92271ae9b61f1411f663fead06b2cf5074b20413700086af07e5","n":8192,"r":8,"p":1},"mac":"e374cccee0d8990610d30ce1a69e3a3a814f74d02aafec4fd7107941f7d53b33"}},
"password": "password",
"abi": [
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "string"
}
],
"name": "getClaim",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_owner",
"type": "string"
},
{
"name": "_claimContent",
"type": "string"
}
],
"name": "setClaim",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
],
"contractAddress": "0x1c5d5a2298ee5e71c69debba12e13721f4da6093",
"method": "setClaim",
"parameters": ["Junwei", "123" ]
}
```
#### Sample Response
```
{
"host": "node9.puyuma.org",
"port": 8080,
"tx": {
"from": {
"value": "0xc772123056A6EEAFBe4Bc0d9a2963A7181682553"
},
"to": {
"value": "0x1c5d5a2298ee5e71c69debba12e13721f4da6093"
},
"gas": 1000000,
"gasPrice": 0,
"chainId": 1,
"data": "0x2df3f82a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000064a756e776569000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033132330000000000000000000000000000000000000000000000000000000000",
"nonce": 14
},
"constant": false,
"signedTX": {
"messageHash": "0xc8d877c90d9151149cf653920eea2e09701514b3f3b3070b04ea61793cb16199",
"v": "0x26",
"r": "0xb2d781689d3f95c929370ed2df496f50a26c9d6072b27cd312c20f7743bccfe4",
"s": "0x7c10b1531c218eeaf72b55af9887c2c70f2f3c1f9ab8ae4a0f00b3503755fb3b",
"rawTransaction": "0xf901250e80830f4240941c5d5a2298ee5e71c69debba12e13721f4da609380b8c42df3f82a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000064a756e77656900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003313233000000000000000000000000000000000000000000000000000000000026a0b2d781689d3f95c929370ed2df496f50a26c9d6072b27cd312c20f7743bccfe4a07c10b1531c218eeaf72b55af9887c2c70f2f3c1f9ab8ae4a0f00b3503755fb3b"
},
"hash": "0xf383ecca4f87c06128793f142551f1377220cab35d2654431a1a30379d4f7891"
}
```