我牢固地编写了一个智能合约,按照smart Contract中的说明从树莓派接收数据,并将其部署在testrpc中。我使用了相同的帐户来部署智能合约以及树莓派地址。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<div class="container-fluid mt-5">
<form id="custom_price_calculator">
<div class="form-row">
<div class="col-md-3 col-4 mb-3">
<label for="inputCalculatorQty" class="font-weight-bolder">Quantity</label>
<input type="number" class="form-control" id="inputCalculatorQty" value="1" min="1" required>
</div>
<div class="col-md-3 col-4 mb-3">
<label for="inputCalculatorUnitPrice" class="font-weight-bolder">Unit Price</label>
<input type="number" class="form-control" id="inputCalculatorUnitPrice" min="0.01" value="1.19" required disabled>
</div>
<div class="col-md-3 col-4 mb-3">
<label for="inputCalculatorQty" class="font-weight-bolder">Origination</label>
<input type="number" class="form-control" id="inputCalculatorQty" value="100" min="1" required>
</div>
<div class="col-md-3 mt-md-4 mb-3">
<button class="btn btn-primary btn-sweets btn-block" type="submit"><i class="fas fa-calculator"></i> Calculate price</button>
</div>
</div>
</form>
</div>
我希望使用web3.py将传感器数据从树莓派发送到智能合约。我尝试设置使用web3.py调用智能合约的阈值限制。
`pragma solidity ^0.5.4;
contract StoreIntegerValue{
address owner;
int sensorData;
constructor (int _sensorData) public {
sensorData = _sensorData;
owner = msg.sender;
}
function setSensorData(int _sensorData) public {
require(msg.sender == owner);
sensorData = _sensorData;
}
function getSensorData() public returns (int) {
require(msg.sender == owner);
return sensorData;
}
}`
代码web3和solidity都没有错误运行,但是作为事务的结果,我在testrpc中看不到任何新的块形成。是否有兴趣知道是否按照代码发送数据?如果正在发送,为什么不形成块?我的代码中是否存在语义错误?请为我提供解决方案或任何潜在的解决方案。