hi,all:
How truffle framework combine with nodejs express framework ,then provide service like express framewok。For example,I want invoke smart contract as follow:
"
var express = require('express');
var app = express();
app.get('/a', function (req, res) {
// invoke a smart contract
res.send(result);
})
app.get('/b', function (req, res) {
// invoke b smart contract
res.send(result);
})
var server = app.listen(8081, function () {
var host = server.address().address
var port = server.address().port
console.log("http://%s:%s", host, port)
})
"
The truffle framework I using was downloaded from github。
Hi there. This would be the perfect use for a Truffle Box. See here: http://truffleframework.com/boxes/
We currently don't have a Truffle Box for Express, but please feel free to create one and submit your code to us -- we'll be happy to list it. CC @DiscRiskandBisque
I guess the question is more about how to co-exist pages rendered by express and ones served by truffle (with npm run dev)
We have the box which can be used to provide api end points to the smart-contract using express...
It invokes smart contracts from the get/post requests.. http://truffleframework.com/boxes/express-box
Most helpful comment
We have the box which can be used to provide api end points to the smart-contract using express...
It invokes smart contracts from the get/post requests.. http://truffleframework.com/boxes/express-box