我正在使用 Node.js 构建一个去中心化应用程序。我需要 node.js 应用程序从前端接收消息,使用 web3.js 签署消息并将签名发送回前端。
我正在考虑将预定义的私钥作为环境变量传递给 node.js 应用程序。然后使用私钥实例化Web3并调用web3.personal.sign对消息进行签名。我需要在服务器端进行签名过程,所以我不认为使用像 Metamask 这样的客户端钱包是适用的。
我是区块链和 Web3 开发的新手,所以我不确定我的要求是否可行。
“迁移”在部署时遇到无效的操作码。尝试:
我的migration.sol代码
// SPDX-License-Identifier: UNLICENSED
//the version of solidity that is compatible
pragma solidity ^0.8.0;
contract Migrations {
address public owner = msg.sender;
uint public last_completed_migration;
modifier restricted() {
require(
msg.sender == owner,
"This function is restricted to the contract's owner"
);
_;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
}
Run Code Online (Sandbox Code Playgroud)
我的松露 config.js 文件
// SPDX-License-Identifier: UNLICENSED
//the version of solidity that is compatible
pragma solidity ^0.8.0;
contract Migrations {
address public owner …Run Code Online (Sandbox Code Playgroud) 我试图解码类似于以下格式的十六进制字符串:
0x00000000000000000000000000000000000000000000000bf97e2a21966df7fe
Run Code Online (Sandbox Code Playgroud)
我能够使用在线计算器对其进行解码.应该是正确的解码数字220892037897060743166.
但是,当我尝试使用python使用以下代码对其进行解码时,它会返回错误:
"0x00000000000000000000000000000000000000000000000bf97e2a21966df7fe".decode("hex")
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-32-1cf86ff46cbc> in <module>()
9 key=keyarr[0]
10
---> 11 "0x00000000000000000000000000000000000000000000000bf97e2a21966df7fe".decode("hex")
/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/hex_codec.py in hex_decode(input, errors)
40 """
41 assert errors == 'strict'
---> 42 output = binascii.a2b_hex(input)
43 return (output, len(input))
44
TypeError: Non-hexadecimal digit found
Run Code Online (Sandbox Code Playgroud)
然后我删除了十六进制数字前面的0x并再次尝试:
"00000000000000000000000000000000000000000000000bf97e2a21966df7fe".decode("hex")
Run Code Online (Sandbox Code Playgroud)
然后输出成为:
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b\xf9~*!\x96m\xf7\xfe'
Run Code Online (Sandbox Code Playgroud)
我实际上不明白输出...
如果您想知道这些数字来自何处,它们来自以太坊区块链(ERC20)令牌.
我正在使用IBM bluemix区块链服务为我的资产共享演示试用一些智能合约逻辑.
无论如何,在超级分层结构网络中查询资产修改的历史记录.
我已经检查了Fabric 0.6和1.0版本的文档,但我只能找到stub.pushState(key,value_json)和stub.getState(key)来交换分类帐的宽度.
但是使用stub.getState(key),我只能获取密钥的最新条目,但是如何获取和显示为同一个密钥编写的一系列更改/修改.我已使用迭代遍历块{peeraddress}/Block/getBlock/{Block},但我只获得加密的事务有效负载,因为它的安全性已经开启.我没有想到显示相同密钥的资产修改历史.
请建议我这样做的正确方法.
提前致谢
通过遵循Hyperledger-fabric文档并使用fabric-sdk-java客户端,我已经建立了Hyperledger Fabric V1.0网络,我能够从Java应用程序与网络进行通信。现在,在开发设置中一切正常。但是我仍然不清楚其生产水平的实现。寻找以下方面的有价值的建议,以使其投入生产。
我可以在CentOS linux服务器中使用hyperledger composer部署业务网络,但是在使用composer-rest-server生成REST api时却出现连接错误?
[root@bctlpblockchain03 ~]#composer network ping -c admin@tutorial-network
The connection to the network was successfully tested: tutorial-network
version: 0.15.2
participant: org.hyperledger.composer.system.NetworkAdmin#admin
Command succeeded
[root@bctlpblockchain03 ~]# composer-rest-server
? Enter the name of the business network card to use: admin@tutorial-network
? Specify if you want namespaces in the generated REST API: never use namespaces
? Specify if you want to enable authentication for the REST API using Passport:
No
? Specify if you want to enable event publication over WebSockets: …Run Code Online (Sandbox Code Playgroud) 问题是津贴和批准真的在做什么?
这是什么_spender以及它在做什么?
有人能解释一下吗???
contract Token {
uint256 public totalSupply;
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 value) returns (bool success);
function transferFrom(address _from, address _to, uint256 value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
Run Code Online (Sandbox Code Playgroud) 我目前正在进行一个项目,该项目将以太坊等公共区块链与Hyperledger Fabric等财团区块链进行比较。
我将在两个平台上设计和实施智能合约,以衡量其交易速度和成本。
将对其他内容进行比较,例如隐私,潜在的可伸缩性,治理和共识协议。
希望在Solidity中编写Eth智能合约,在Golang中编写Fabric。我对此的经验极少,因此我只想实现基本的合同合同,在两个平台上执行多个合同并进行比较。
有没有办法对模拟真实事物的智能合约进行虚拟运行?
Substrate支持“可插入共识”,因此开发人员可以从几种共识算法中进行选择。它标配有四种算法:
Some of these (eg babe and grandpa) can even be used together in a single node. What are the differences between each consensus algorithm, and which ones can or should be used together?
我创建了一个结构网络,它运行良好。我想更新oderer配置,例如batchtimeout在运行中的网络中。我已按照本教程在运行时更新通道配置。本教程适用于添加新组织。但是当我更新订购者配置时,我得到了如下错误
错误:状态发生意外:BAD_REQUEST-将配置更新应用于现有通道“ mychannel”时出错:授权更新:错误验证DeltaSet:未满足[Value] / Channel / Orderer / BatchTimeout的策略:隐式策略评估失败-0子-符合政策,但此政策要求满足“管理员”子政策中的1个
我从所有组织管理员(例如org1和org2)中选择了信封.pb文件。请帮助我。
注意:为此,我使用了fabric-samples第一网络。
编辑:我已经用org1和org2签署了pb文件。我还通过导出以下变量与订购者签署了文件
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin\@example.com/msp/
CORE_PEER_ADDRESS=orderer.example.com:7050
CORE_PEER_LOCALMSPID=OrdererMSP
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
Run Code Online (Sandbox Code Playgroud)
日志
11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc4 Manager Channel/Orderer looking up path []
2019-11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc5 Manager Channel/Orderer has managers OrdererOrg
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc6 == Evaluating *policies.implicitMetaPolicy Policy /Channel/Orderer/Admins ==
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc7 This is an implicit meta policy, it will trigger other …Run Code Online (Sandbox Code Playgroud) blockchain hyperledger hyperledger-fabric hyperledger-chaincode
blockchain ×10
ethereum ×4
hyperledger ×4
ibm-cloud ×2
solidity ×2
centos ×1
consensus ×1
cryptography ×1
hex ×1
javascript ×1
linux ×1
node.js ×1
p2p ×1
parity-io ×1
python ×1
substrate ×1
web3js ×1