sails-hook-truffle
v1.0.35
Published
A hook for sails.js which handles parsing and instantiation of contracts on Ethereum based consensus networks via truffle.
Downloads
17
Maintainers
Readme
sails-hook-truffle
A hook for sails.js which handles parsing and instantiation of contracts on Ethereum based consensus networks via truffle.
Installing the Hook
On existing Sails & Truffle projects:
- Copy contracts folder and truffle.js (or truffle-config.js depending on which your project is using) from your truffle project into the sails project.
- In your sails project, run
npm install -s sails-hook-truffle
Usage:
If your contract's filename is ContractName.sol
:
on the server side you can interact with your contract using:
sails.ContractName.deployed().then((contractName)=>{
// include method calls here, or return instance for
// functionality outside of callback
})
on the clientSide:
io.socket.get('/contracts/ContractName', (ContractName) =>{
contractName = web3.eth.contract(ContractName.abi).at(ContractName.address);
// include method calls here, or return instance for
// functionality outside of callback
}