# StakeStone API References

Before we proceed, it is essential to have a basic understanding of programming concepts related to blockchain. This includes familiarity with Ethereum and its associated concepts such as smart contracts, and the Solidity programming language, as well as popular development environments like Remix, Truffle, Hardhat, and others.

## Vault-Related

### Deposit ETH to vault

**Description**

Make a deposit to StakeStone vault, and the caller will get STONE tokens as the vault shares.

**Function Description**

<table><thead><tr><th width="215.5">Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StoneVault contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StoneVault.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity"><strong>    function deposit()
</strong>        external
        payable
        nonReentrant
        returns (uint256 mintAmount)
</code></pre></td></tr><tr><td>Function Selector</td><td>0xd0e30db0</td></tr><tr><td>Invocation Type</td><td>Ethereum Transaction</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td>mintAmount, the STONE tokens minted</td></tr><tr><td>Event Emitted</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">    event Deposit(
        address indexed account,
        uint256 amount,
        uint256 mint,
        uint256 round
    );
</code></pre></td></tr><tr><td>Event Signature</td><td>0x36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [],
  "name": "deposit",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "mintAmount",
      "type": "uint256"
    }
  ],
  "stateMutability": "payable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StoneVault contract address
const CONTRACT_ADDRESS = "";
const ABI = [    {
      "inputs": [],
      "name": "deposit",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "mintAmount",
          "type": "uint256"
        }
      ],
      "stateMutability": "payable",
      "type": "function"
    }];

// Deposit 1 Ether.
const DEPOSIT_AMOUNT = 1e18;

var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.deposit().send({
    from: "CALLER_ADDRESS",
    value: BigNumber(DEPOSIT_AMOUNT).toString(10)
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Make a deposit to vault

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Make a deposit transaction to StakeStone vault.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                           |
| ----------------------------------------- | ------ | ----------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                                 |
| method<mark style="color:red;">\*</mark>  | String | "eth\_sendRawTransaction"                             |
| params<mark style="color:red;">\*</mark>  | Array  | the signed transaction data coerced into string array |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id    |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Make a withdrawal request from vault

**Description**

Make a withdrawal request from Vault. User could retrieve ETH principal and yields from vault after vault has been settled.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StoneVault contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StoneVault.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function requestWithdraw(uint256 _shares) external
</code></pre></td></tr><tr><td>Function Selector</td><td>0x745400c9</td></tr><tr><td>Invocation Type</td><td>Ethereum Transaction</td></tr><tr><td>Passing Parameters</td><td><strong>uint256 _shares</strong>, the STONE amount to withdraw; actual number multiplied by 1E18</td></tr><tr><td>Return Value</td><td>None.</td></tr><tr><td>Event Emitted</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">    event InitiateWithdraw(
        address indexed account,
        uint256 shares,
        uint256 round
    );
</code></pre></td></tr><tr><td>Event Signature</td><td>0x0c53c82ad07e2d592d88ece3b066777dd60f1118e2a081b380efc4358f0d9e2a</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "uint256",
      "name": "_shares",
      "type": "uint256"
    }
  ],
  "name": "requestWithdraw",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StoneVault contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
      "inputs": [
        {
          "internalType": "uint256",
          "name": "_shares",
          "type": "uint256"
        }
      ],
      "name": "requestWithdraw",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }];

// Withdraw 1 STONE.
const WITHDRAW_AMOUNT = 1e18;

var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.requestWithdraw(WITHDRAW_AMOUNT).send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Make a withdrawal request from vault.&#x20;

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Make a withdrawal request transaction from vault.&#x20;

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                           |
| ----------------------------------------- | ------ | ----------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                                 |
| method<mark style="color:red;">\*</mark>  | String | "eth\_sendRawTransaction"                             |
| params<mark style="color:red;">\*</mark>  | Array  | the signed transaction data coerced into string array |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id    |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Cancel withdrawal request

**Description**

Cancel a previous withdrawal request to get pending STONE back.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StoneVault contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StoneVault.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function cancelWithdraw(uint256 _shares) external
</code></pre></td></tr><tr><td>Function Selector</td><td>0x9f01f7ba</td></tr><tr><td>Invocation Type</td><td>Ethereum Transaction</td></tr><tr><td>Passing Parameters</td><td><strong>uint256 _shares</strong>, the STONE amount to cancel; actual number multiplied by 1E18</td></tr><tr><td>Return Value</td><td>None.</td></tr><tr><td>Event Emitted</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">    event CancelWithdraw(
        address indexed account,
        uint256 amount,
        uint256 round
    );
</code></pre></td></tr><tr><td>Event Signature</td><td>0x39e2e01794006bc1f63835af5c05db790beca4bfb40de3f02cc3ddf22dccc0fb</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "uint256",
      "name": "_shares",
      "type": "uint256"
    }
  ],
  "name": "cancelWithdraw",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StoneVault contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [
    {
      "internalType": "uint256",
      "name": "_shares",
      "type": "uint256"
    }
  ],
  "name": "cancelWithdraw",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}];

// Cancel 1 STONE's withdrawal.
const STONE_AMOUNT = 1e18;

var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.cancelWithdraw(STONE_AMOUNT).send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Cancel withdrawal request

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Cancel a former withdrawal request to get pending STONE back.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                           |
| ----------------------------------------- | ------ | ----------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                                 |
| method<mark style="color:red;">\*</mark>  | String | "eth\_sendRawTransaction"                             |
| params<mark style="color:red;">\*</mark>  | Array  | the signed transaction data coerced into string array |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id    |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Query current STONE price

**Description**

Query the real-time STONE price(quoted by ETH price).

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StoneVault contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StoneVault.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function currentSharePrice() public returns (uint256 price)
</code></pre></td></tr><tr><td>Function Selector</td><td>0x28a79576</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>uint256 price</strong>, the price of STONE</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [],
  "name": "currentSharePrice",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "price",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StoneVault contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [],
  "name": "currentSharePrice",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "price",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}];

var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.currentSharePrice().call({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query current STONE price

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Query the real-time STONE price(quoted by ETH price).

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Query historical STONE price

**Description**

Query the historical STONE price by settlement round (quoted by ETH price).

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StoneVault contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StoneVault.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function roundPricePerShare(uint256 _round) public returns (uint256 price)
</code></pre></td></tr><tr><td>Function Selector</td><td>0x87153eb1</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>uint256 price</strong>, the price of STONE</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "name": "roundPricePerShare",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StoneVault contract address
const CONTRACT_ADDRESS = "";
const ABI = [    {
      "inputs": [],
      "name": "deposit",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "mintAmount",
          "type": "uint256"
        }
      ],
      "stateMutability": "payable",
      "type": "function"
    }];

// Round 1.
const ROUND = 1;

var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.roundPricePerShare(ROUND).call({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query historical STONE price

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Query the historical STONE price by settlement round (quoted by ETH price).

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the transaction data coerced into string array     |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Query latest settlement round

**Description**

Query the latest settlement round of StakeStone vault.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StoneVault contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StoneVault.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function latestRoundID() public returns (uint256 price)
</code></pre></td></tr><tr><td>Function Selector</td><td>0xf76339dc</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>uint256 round</strong>, the latest settlement round</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [],
  "name": "latestRoundID",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StoneVault contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [],
  "name": "latestRoundID",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.latestRoundID().call({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query latest settlement round

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Query the latest settlement round of StakeStone vault.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Query withdraw fee rate

**Description**

Query withdraw fee rate of StakeStone vault(multiplied by 1E6).

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StoneVault contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StoneVault.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function withdrawFeeRate() public returns (uint256 price)
</code></pre></td></tr><tr><td>Function Selector</td><td>0xea99e689</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>uint256 rate</strong>, withdraw fee rate(multiplied by 1E6)</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [],
  "name": "withdrawFeeRate",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StoneVault contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [],
  "name": "withdrawFeeRate",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.withdrawFeeRate().call({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query withdraw fees

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Query withdraw fee rate of StakeStone vault(multiplied by 1E6).

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

## Strategy-Related

### Query all strategies of the portfolio

**Description**

Get all smart contract address of strategies.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StrategyController contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StrategyController.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function getStrategies() public view
    returns (address[] memory addrs, uint256[] memory portions)
</code></pre></td></tr><tr><td>Function Selector</td><td>0xb49a60bb</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>address[] memory addrs</strong>, the array of strategy address<br><strong>uint256[] memory portions</strong>, the array of the portions of each strategy</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [],
  "name": "getStrategies",
  "outputs": [
    {
      "internalType": "address[]",
      "name": "addrs",
      "type": "address[]"
    },
    {
      "internalType": "uint256[]",
      "name": "portions",
      "type": "uint256[]"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StrategyController contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [],
  "name": "getStrategies",
  "outputs": [
    {
      "internalType": "address[]",
      "name": "addrs",
      "type": "address[]"
    },
    {
      "internalType": "uint256[]",
      "name": "portions",
      "type": "uint256[]"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.getStrategies().send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query all strategies of the portfolio

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Get all smart contract address of strategies.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Query ethers deployed on all strategies

**Description**

Get ethers amount deployed on all strategies.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StrategyController contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StrategyController.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function getAllStrategiesValue() public returns (uint256 _value)
</code></pre></td></tr><tr><td>Function Selector</td><td>0xb49a60bb</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>uint256 value</strong>, ether amount(multiplied by 1E18)</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [],
  "name": "getAllStrategiesValue",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "_value",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StrategyController contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [],
  "name": "getAllStrategiesValue",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "_value",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.getAllStrategiesValue().send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query ethers deployed on all strategies

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Get ethers amount deployed on all strategies.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Query ethers deployed on certain strategy

**Description**

Get ether amount deployed on certain strategy.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>StrategyController contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>StrategyController.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">    function getStrategyValue(
        address _strategy
    ) public returns (uint256 _value) 
</code></pre></td></tr><tr><td>Function Selector</td><td>0x9841ab00</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>uint256 value</strong>, ether amount(multiplied by 1E18)</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "address",
      "name": "_strategy",
      "type": "address"
    }
  ],
  "name": "getStrategyValue",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "_value",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need StrategyController contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [
    {
      "internalType": "address",
      "name": "_strategy",
      "type": "address"
    }
  ],
  "name": "getStrategyValue",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "_value",
      "type": "uint256"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.getStrategyValue().send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query ethers deployed on certain strategy

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Get ether amount deployed on certain strategy.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

## Vote-Related

### Query all proposals

**Description**

Get all smart contract address of proposals.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>Proposal contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>Proposal.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function getProposals() public view returns (address[] memory addrs)
</code></pre></td></tr><tr><td>Function Selector</td><td>0x62564c48</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td>None.</td></tr><tr><td>Return Value</td><td><strong>address[] memory addrs</strong>, the array of proposal address</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [],
  "name": "getProposals",
  "outputs": [
    {
      "internalType": "address[]",
      "name": "addrs",
      "type": "address[]"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need Proposal contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [],
  "name": "getProposals",
  "outputs": [
    {
      "internalType": "address[]",
      "name": "addrs",
      "type": "address[]"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.getProposals().call({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query all proposals

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Get all smart contract address of proposals.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Query vote info on certain proposal

**Description**

Get the proposal details.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>Proposal contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>Proposal.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function proposalDetails(address _proposal) public view 
  returns (
        address proposer,
        uint256 deadline,
        uint256 support,
        uint256 oppose,
        uint256 executedTime,
        bytes data
  )
</code></pre></td></tr><tr><td>Function Selector</td><td>0x3b23c36d</td></tr><tr><td>Invocation Type</td><td>Ethereum Call</td></tr><tr><td>Passing Parameters</td><td><strong>address _proposal</strong>, proposal address</td></tr><tr><td>Return Value</td><td><strong>address proposal</strong>, the address propose the proposal<br><strong>uint256 deadline</strong>, the deadline of voting period<br><strong>uint256 support</strong>, the vote amount of supporting the proposal<br><strong>uint256 oppose</strong>, the vote amount of opposing the proposal<br><strong>uint256 executedTime</strong>, the timestamp of executing the proposal<br><strong>bytes data</strong>, proposal data</td></tr><tr><td>Event Emitted</td><td>None.</td></tr><tr><td>Event Signature</td><td>None.</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "address",
      "name": "",
      "type": "address"
    }
  ],
  "name": "proposalDetails",
  "outputs": [
    {
      "internalType": "address",
      "name": "proposer",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "deadline",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "support",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "oppose",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "executedTime",
      "type": "uint256"
    },
    {
      "internalType": "bytes",
      "name": "data",
      "type": "bytes"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need Proposal contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [
    {
      "internalType": "address",
      "name": "",
      "type": "address"
    }
  ],
  "name": "proposalDetails",
  "outputs": [
    {
      "internalType": "address",
      "name": "proposer",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "deadline",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "support",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "oppose",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "executedTime",
      "type": "uint256"
    },
    {
      "internalType": "bytes",
      "name": "data",
      "type": "bytes"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.proposalDetails(PROPOSAL_ADDRESS).call({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Query vote info on certain proposal

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Get the proposal details.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_call"                                        |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Vote for a proposal

**Description**

Voting for a proposal by staking with STONE.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>Proposal contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>Proposal.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function voteFor(address _proposal, uint256 _poll, bool _flag) external
</code></pre></td></tr><tr><td>Function Selector</td><td>0x31547ea6</td></tr><tr><td>Invocation Type</td><td>Ethereum Transaction</td></tr><tr><td>Passing Parameters</td><td><strong>address _proposal</strong>, the proposal address<br><strong>uint256 _poll</strong>, the STONE amount will be staked which represents the voting power<br><strong>bool _flag</strong>, true represents the supporting of a proposal</td></tr><tr><td>Return Value</td><td>None.</td></tr><tr><td>Event Emitted</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">event VoteFor(address proposal, uint256 poll, bool flag);
</code></pre></td></tr><tr><td>Event Signature</td><td>0xdf4863bb3c37bd8d486548a8abd33fb356c8536cbb1111b676b1810d64447544</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "address",
      "name": "_proposal",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "_poll",
      "type": "uint256"
    },
    {
      "internalType": "bool",
      "name": "_flag",
      "type": "bool"
    }
  ],
  "name": "voteFor",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need Proposal contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [
    {
      "internalType": "address",
      "name": "_proposal",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "_poll",
      "type": "uint256"
    },
    {
      "internalType": "bool",
      "name": "_flag",
      "type": "bool"
    }
  ],
  "name": "voteFor",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.voteFor(PROPOSAL_ADDRESS, STONE_AMOUNT, true).send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Vote for a proposal

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Voting for a proposal by staking with STONE.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_sendRawTransaction"                          |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Retrieve STONEs voted for certain proposal

**Description**

Voting for a proposal by staking with STONE.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>Proposal contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>Proposal.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function voteFor(address _proposal, uint256 _poll, bool _flag) external
</code></pre></td></tr><tr><td>Function Selector</td><td>0x31547ea6</td></tr><tr><td>Invocation Type</td><td>Ethereum Transaction</td></tr><tr><td>Passing Parameters</td><td><strong>address _proposal</strong>, the proposal address<br><strong>uint256 _poll</strong>, the STONE amount will be staked which represents the voting power<br><strong>bool _flag</strong>, true represents the supporting of a proposal</td></tr><tr><td>Return Value</td><td>None.</td></tr><tr><td>Event Emitted</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">event VoteFor(address proposal, uint256 poll, bool flag);
</code></pre></td></tr><tr><td>Event Signature</td><td>0xdf4863bb3c37bd8d486548a8abd33fb356c8536cbb1111b676b1810d64447544</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "address",
      "name": "_proposal",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "_poll",
      "type": "uint256"
    },
    {
      "internalType": "bool",
      "name": "_flag",
      "type": "bool"
    }
  ],
  "name": "voteFor",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need Proposal contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [
    {
      "internalType": "address",
      "name": "_proposal",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "_poll",
      "type": "uint256"
    },
    {
      "internalType": "bool",
      "name": "_flag",
      "type": "bool"
    }
  ],
  "name": "voteFor",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.voteFor(PROPOSAL_ADDRESS, STONE_AMOUNT, true).send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Vote for a proposal

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Voting for a proposal by staking with STONE.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_sendRawTransaction"                          |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}

### Retrieve STONEs voted for all proposals

**Description**

Voting for a proposal by staking with STONE.

**Function Description**

<table><thead><tr><th>Items</th><th>Description</th></tr></thead><tbody><tr><td>Contract Address</td><td>Proposal contract (referenced by <a href="/pages/8hBCSAz8A8iNufQ6CS5q">Smart Contracts Address section</a>)</td></tr><tr><td>Contract Name</td><td>Proposal.sol</td></tr><tr><td>Function Name</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">function voteFor(address _proposal, uint256 _poll, bool _flag) external
</code></pre></td></tr><tr><td>Function Selector</td><td>0x31547ea6</td></tr><tr><td>Invocation Type</td><td>Ethereum Transaction</td></tr><tr><td>Passing Parameters</td><td><strong>address _proposal</strong>, the proposal address<br><strong>uint256 _poll</strong>, the STONE amount will be staked which represents the voting power<br><strong>bool _flag</strong>, true represents the supporting of a proposal</td></tr><tr><td>Return Value</td><td>None.</td></tr><tr><td>Event Emitted</td><td><p></p><pre class="language-solidity"><code class="lang-solidity">event VoteFor(address proposal, uint256 poll, bool flag);
</code></pre></td></tr><tr><td>Event Signature</td><td>0xdf4863bb3c37bd8d486548a8abd33fb356c8536cbb1111b676b1810d64447544</td></tr></tbody></table>

**ABI Description**

```json
{
  "inputs": [
    {
      "internalType": "address",
      "name": "_proposal",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "_poll",
      "type": "uint256"
    },
    {
      "internalType": "bool",
      "name": "_flag",
      "type": "bool"
    }
  ],
  "name": "voteFor",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}
```

**Samples**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Javascript example
</strong><strong>var Web3 = require('web3');
</strong>const BigNumber = require('bignumber.js');

const  web3 = new Web3("RPC Endpoint Url");

// Need Proposal contract address
const CONTRACT_ADDRESS = "";
const ABI = [{
  "inputs": [
    {
      "internalType": "address",
      "name": "_proposal",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "_poll",
      "type": "uint256"
    },
    {
      "internalType": "bool",
      "name": "_flag",
      "type": "bool"
    }
  ],
  "name": "voteFor",
  "outputs": [],
  "stateMutability": "nonpayable",
  "type": "function"
}];


var contract = new web3.eth.Contract(ABI, CONTRACT_ADDRESS);

contract.methods.voteFor(PROPOSAL_ADDRESS, STONE_AMOUNT, true).send({
    from: "CALLER_ADDRESS"
}, function(error, result){
    if(!error) {
      console.log('Response:', result);
    } else {
      console.log(error);
    }
});
</code></pre>

HTTP Request Example

## Vote for a proposal

<mark style="color:green;">`POST`</mark> `(RPC Endpoint)`

Voting for a proposal by staking with STONE.

\
More details on how to send a transaction via RPC endpoint could be found here, <https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction>

#### Request Body

| Name                                      | Type   | Description                                        |
| ----------------------------------------- | ------ | -------------------------------------------------- |
| jsonrpc<mark style="color:red;">\*</mark> | String | "2.0"                                              |
| method<mark style="color:red;">\*</mark>  | String | "eth\_sendRawTransaction"                          |
| params<mark style="color:red;">\*</mark>  | Array  | the call data coerced into string array            |
| id<mark style="color:red;">\*</mark>      | Number | request sequence id, you could use timestamp as id |

{% tabs %}
{% tab title="200: OK Success response." %}

```
{
  "id":64,
  "jsonrpc": "2.0",
  "result": "TRANSCACTION HASH with 0x prefix"
}
```

{% endtab %}
{% endtabs %}


---

# 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.stakestone.io/stakestone/developers/stakestone-api-references.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.
