This webserver provides an interface to communicate with Ethereum Smart Contracts over HTTP.
Clone the repository
git clone [email protected]:legalthings/web3-server.git
Install dependencies
cd <project_name>
npm install
Build and run the project
npm start
The project by default runs TestRPC on http://localhost:8545
.
This is useful for development and testing because its fast.
However, if the server restarts the stored state is reset.
For production you should run your own node via Geth and then configure the url/port to a different endpoint.
Configuration can be found here. Each environment and hostname can have its own configuration file.
Certain pieces of the configuration can be configured through environment variables.
Variable | Description |
---|---|
ETH_WEB3_URL |
The url used to connect Web3 to the ethereum node. |
ETH_WEB3_ADDRESS |
The default wallet address used to make transactions. |
Predefined Smart Contracts can be added to the project in this folder. These contracts can then be instantiated and invoked by using the API.
You can add a contract by first creating a folder with the name of the contract. Within that folder add the following files.
| - my-contract
| - contract.sol | The smart contract written in Solidity
| - contract.abi | The smart contract application binary interface, used in JSON-RPC requests
| - contract.bytecode | The smart contract compiled to bytecode, used to deploy it to the blockchain
Api documentation can be found here.