Skip to content

Polkamarkets/polkamarkets-rpc

Repository files navigation

polkamarkets-rpc

HTTP web3 wrapper for polkamarkets-js

Installation

Setup WEB3_PROVIDER env variable (e.g., Infura for Ethereum dapps)

yarn install
yarn dev

Usage

Smart Contract Method Queries:

// method - method name (example: getMarketData)
// args - method arguments, comma separated (example: 1,2)
// contractAddress - smart contract address (example: 0xDcBe79f74c98368141798eA0b7b979B9bA54b026)

http://localhost:3333/call?contract=predictionMarket&method=${method}&args=${args}&address=${contractAddress}

Smart Contract Event Queries:

// eventName - event name (example: MarketActionTx)
// filter - event filter json (example: {"marketId":"1"})
// contractAddress - smart contract address (example: 0xDcBe79f74c98368141798eA0b7b979B9bA54b026)

http://localhost:3333/events?contract=predictionMarket&eventName=${eventName}&address=${contractAddress}&filter=${filter}

Generate Private/Public Key pair to protect execute calls

openssl genrsa -out private_key.pem 4096
openssl rsa -pubout -in private_key.pem -out public_key.pem

Contribution

Contributions are welcomed but we ask to red existing code guidelines, specially the code format. Please review Contributor guidelines

License

MIT

Notes

The usage of ETH in all methods or params means using the native currency of that blockchain, example BSC in Binance Chain would still be nominated as ETH