最近有人问我为什么我们的网站在没有 cookie 的情况下无法运行。我的解释是我们需要在 cookie 中保存令牌和一些引用,以便稍后我们可以使用它来发出请求,并且我们可以使用限制选项在浏览器中保存数据。但是他对我的回答并不满意,而且我还认为我们可以通过一些选项使其工作,而不是使用 cookie/localStorage/sessionStorage。
我的问题是为什么大多数网站在没有 cookie 的情况下无法运行?我们可以让网站在浏览器中没有任何存储的情况下运行吗?
我使用testrpc,web3 1.0和solidity来构建一个简单的Dapp,但我总是得到这个错误,我找不到有什么问题.请帮忙.
我的javascript文件:
const Web3 = require('web3');
const fs = require('fs');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
const code = fs.readFileSync('Voting.sol').toString();
const solc = require('solc');
const compiledCode = solc.compile(code);
// deploy contract
const abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface);
const VotingContract = new web3.eth.Contract(abiDefinition);
const byteCode = compiledCode.contracts[':Voting'].bytecode;
const deployedContract = VotingContract
.deploy({data: byteCode, arguments: [['a','b','c']]})
.send({
from: '0x386fd5fbe3804f24b35477f06aa78a178ce021bd',
gas: 4700000,
gasPrice: '2000000000'
}, function(error, transactionHash) {})
.on('error', function(error){})
.on('transactionHash', function(transactionHash){})
.on('receipt', function(receipt){
console.log(receipt.contractAddress);
})
.then(function(newContractInstance) {
newContractInstance.methods.getList().call({from: '0x386fd5fbe3804f24b35477f06aa78a178ce021bd'}).then(console.log);
});
Run Code Online (Sandbox Code Playgroud)
我的合同文件:
pragma solidity …Run Code Online (Sandbox Code Playgroud)