StakeStone API References

This page describes detailed technical interfaces on StakeStone, including interface definitions, listed parameters, return values and call samples of different programming languages and environments.

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.

Deposit ETH to vault

Description

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

Function Description

Items
Description

Contract Address

Contract Name

StoneVault.sol

Function Name

Function Selector

0xd0e30db0

Invocation Type

Ethereum Transaction

Passing Parameters

None.

Return Value

mintAmount, the STONE tokens minted

Event Emitted

Event Signature

0x36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Make a deposit to vault

POST (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*

String

"2.0"

method*

String

"eth_sendRawTransaction"

params*

Array

the signed transaction data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

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

Items
Description

Contract Address

Contract Name

StoneVault.sol

Function Name

Function Selector

0x745400c9

Invocation Type

Ethereum Transaction

Passing Parameters

uint256 _shares, the STONE amount to withdraw; actual number multiplied by 1E18

Return Value

None.

Event Emitted

Event Signature

0x0c53c82ad07e2d592d88ece3b066777dd60f1118e2a081b380efc4358f0d9e2a

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Make a withdrawal request from vault.

POST (RPC Endpoint)

Make a withdrawal request transaction from 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*

String

"2.0"

method*

String

"eth_sendRawTransaction"

params*

Array

the signed transaction data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Cancel withdrawal request

Description

Cancel a previous withdrawal request to get pending STONE back.

Function Description

Items
Description

Contract Address

Contract Name

StoneVault.sol

Function Name

Function Selector

0x9f01f7ba

Invocation Type

Ethereum Transaction

Passing Parameters

uint256 _shares, the STONE amount to cancel; actual number multiplied by 1E18

Return Value

None.

Event Emitted

Event Signature

0x39e2e01794006bc1f63835af5c05db790beca4bfb40de3f02cc3ddf22dccc0fb

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Cancel withdrawal request

POST (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*

String

"2.0"

method*

String

"eth_sendRawTransaction"

params*

Array

the signed transaction data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query current STONE price

Description

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

Function Description

Items
Description

Contract Address

Contract Name

StoneVault.sol

Function Name

Function Selector

0x28a79576

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

uint256 price, the price of STONE

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query current STONE price

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query historical STONE price

Description

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

Function Description

Items
Description

Contract Address

Contract Name

StoneVault.sol

Function Name

Function Selector

0x87153eb1

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

uint256 price, the price of STONE

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query historical STONE price

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the transaction data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query latest settlement round

Description

Query the latest settlement round of StakeStone vault.

Function Description

Items
Description

Contract Address

Contract Name

StoneVault.sol

Function Name

Function Selector

0xf76339dc

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

uint256 round, the latest settlement round

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query latest settlement round

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query withdraw fee rate

Description

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

Function Description

Items
Description

Contract Address

Contract Name

StoneVault.sol

Function Name

Function Selector

0xea99e689

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

uint256 rate, withdraw fee rate(multiplied by 1E6)

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query withdraw fees

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query all strategies of the portfolio

Description

Get all smart contract address of strategies.

Function Description

Items
Description

Contract Address

Contract Name

StrategyController.sol

Function Name

Function Selector

0xb49a60bb

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

address[] memory addrs, the array of strategy address uint256[] memory portions, the array of the portions of each strategy

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query all strategies of the portfolio

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query ethers deployed on all strategies

Description

Get ethers amount deployed on all strategies.

Function Description

Items
Description

Contract Address

Contract Name

StrategyController.sol

Function Name

Function Selector

0xb49a60bb

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

uint256 value, ether amount(multiplied by 1E18)

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query ethers deployed on all strategies

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query ethers deployed on certain strategy

Description

Get ether amount deployed on certain strategy.

Function Description

Items
Description

Contract Address

Contract Name

StrategyController.sol

Function Name

Function Selector

0x9841ab00

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

uint256 value, ether amount(multiplied by 1E18)

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query ethers deployed on certain strategy

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query all proposals

Description

Get all smart contract address of proposals.

Function Description

Items
Description

Contract Address

Contract Name

Proposal.sol

Function Name

Function Selector

0x62564c48

Invocation Type

Ethereum Call

Passing Parameters

None.

Return Value

address[] memory addrs, the array of proposal address

Event Emitted

None.

Event Signature

None.

ABI Description

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

Samples

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query all proposals

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Query vote info on certain proposal

Description

Get the proposal details.

Function Description

Items
Description

Contract Address

Contract Name

Proposal.sol

Function Name

Function Selector

0x3b23c36d

Invocation Type

Ethereum Call

Passing Parameters

address _proposal, proposal address

Return Value

address proposal, the address propose the proposal uint256 deadline, the deadline of voting period uint256 support, the vote amount of supporting the proposal uint256 oppose, the vote amount of opposing the proposal uint256 executedTime, the timestamp of executing the proposal bytes data, proposal data

Event Emitted

None.

Event Signature

None.

ABI Description

{
  "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

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Query vote info on certain proposal

POST (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*

String

"2.0"

method*

String

"eth_call"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Vote for a proposal

Description

Voting for a proposal by staking with STONE.

Function Description

Items
Description

Contract Address

Contract Name

Proposal.sol

Function Name

Function Selector

0x31547ea6

Invocation Type

Ethereum Transaction

Passing Parameters

address _proposal, the proposal address uint256 _poll, the STONE amount will be staked which represents the voting power bool _flag, true represents the supporting of a proposal

Return Value

None.

Event Emitted

Event Signature

0xdf4863bb3c37bd8d486548a8abd33fb356c8536cbb1111b676b1810d64447544

ABI Description

{
  "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

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Vote for a proposal

POST (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*

String

"2.0"

method*

String

"eth_sendRawTransaction"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Retrieve STONEs voted for certain proposal

Description

Voting for a proposal by staking with STONE.

Function Description

Items
Description

Contract Address

Contract Name

Proposal.sol

Function Name

Function Selector

0x31547ea6

Invocation Type

Ethereum Transaction

Passing Parameters

address _proposal, the proposal address uint256 _poll, the STONE amount will be staked which represents the voting power bool _flag, true represents the supporting of a proposal

Return Value

None.

Event Emitted

Event Signature

0xdf4863bb3c37bd8d486548a8abd33fb356c8536cbb1111b676b1810d64447544

ABI Description

{
  "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

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Vote for a proposal

POST (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*

String

"2.0"

method*

String

"eth_sendRawTransaction"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Retrieve STONEs voted for all proposals

Description

Voting for a proposal by staking with STONE.

Function Description

Items
Description

Contract Address

Contract Name

Proposal.sol

Function Name

Function Selector

0x31547ea6

Invocation Type

Ethereum Transaction

Passing Parameters

address _proposal, the proposal address uint256 _poll, the STONE amount will be staked which represents the voting power bool _flag, true represents the supporting of a proposal

Return Value

None.

Event Emitted

Event Signature

0xdf4863bb3c37bd8d486548a8abd33fb356c8536cbb1111b676b1810d64447544

ABI Description

{
  "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

// Javascript example
var Web3 = require('web3');
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);
    }
});

HTTP Request Example

Vote for a proposal

POST (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*

String

"2.0"

method*

String

"eth_sendRawTransaction"

params*

Array

the call data coerced into string array

id*

Number

request sequence id, you could use timestamp as id

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

Last updated