我开始使用《掌握区块链 - 深入探讨分布式账本、共识协议、智能合约、DApps、加密货币、以太坊》一书进行区块链开发,
我正在使用 WSL 和 geth 版本 1.10.9。
$geth version
Geth
Version: 1.10.9-stable
Git Commit: eae3b1946a276ac099e0018fc792d9e8c3bfda6d
Architecture: amd64
Go Version: go1.17
Operating System: linux
GOPATH=
GOROOT=go
Run Code Online (Sandbox Code Playgroud)
我正在尝试启动 geth,但收到错误消息:未定义 --rpc 标志。
这是我尝试运行的命令:
geth --datadir ~/etherprivate/ --networkid 786 --rpc --rpcapi 'web3,eth,net,debug,personal' --rpccorsdomain '*'
对我如何解决它有任何帮助吗?
尝试使用以太坊来解决区块链问题,在尝试与已部署的合同进行交互时,我遇到了问题.我想要实现的是调用一种方法来显示添加到使用Geth本地部署的私有区块链的信息.
我无法通过我的智能合约调用任何功能,我一直在想我是否做错了什么......有人能告诉我如何从这个合同中简单地调用其中一个方法吗?让我们说出显示现有的代理商,或者用户所属的代理商名称.
我的合同:agency.sol
pragma solidity ^0.4.18;
// We have to specify what version of compiler this code will compile with
contract Agency {
event NewAgency(uint agencyId, string name, uint dna);
uint dnaDigits = 16;
uint dnaModulus = 10 ** dnaDigits;
//agency structure
struct Agency {
string name;
uint dna;
}
Agency[] public agencies;
mapping (uint => address) public agencyToOwner;
mapping (address => uint) ownerAgencyCount;
function _createAgency(string _name, uint _dna) private {
uint id = agencies.push(Agency(_name, _dna)) - 1;
agencyToOwner[id] …Run Code Online (Sandbox Code Playgroud) 我想从账户A在以太坊进行交易,但交易费用应该从账户B支付。在以太坊可以吗?
> w3.eth.syncing
AttributeDict({
'currentBlock': 5787386,
'highestBlock': 5787491,
'knownStates': 138355583,
'pulledStates': 138341120,
'startingBlock': 5787335,
})
> w3.eth.blockNumber
0
Run Code Online (Sandbox Code Playgroud)
我已经完成了完全同步,但块号始终为 0。
我已经使用geth. 我还有一个合约,其中有一个函数调用另一个函数,它是第三个合约来设置地址。我可以在本地区块链上调用这个函数,比如 testRPC 和 Ganache 区块链,即使它在 TestNet 中也能工作。但是一旦我使用 ( geth)设置了私有区块链。我收到此错误:
气体估计错误并显示以下消息(见下文)。事务执行可能会失败。您要强制发送吗?
所需的gas超过限额或总是失败的交易
我在来电者帐户中有足够的 ETH,而且
Run Code Online (Sandbox Code Playgroud)// in contract 1 function func(address addr) public returns (bool result) { Cantract2 c = Cantract2(addr); if (!c.setAddress(..)) { return false; } ..... return true; }
我正在尝试将 Ethers.js 连接到在 Docker 容器中运行的本地 Ehereum 节点 (Geth)。在客户端,我以这种方式创建提供程序:new ethers.providers.JsonRpcProvider('http://geth:8545')。geth是节点容器主机名,并且两个容器位于同一网络上:我可以从客户端容器内 ping Geth 节点。当我开始从客户端请求节点时,出现错误"noNetwork"。
当我在没有 Docker 的情况下运行客户端,通过 请求节点容器时http://localhost:8545,它工作正常。
怎么了?
version: "3.5"
services:
geth:
container_name: geth
image: ethereum/client-go:latest
volumes:
- /etc/geth:/root/.ethereum:rw
ports:
- "8545:8545"
- "30303:30303"
networks:
- ethereum
entrypoint: "geth --nousb --http --http.corsdomain '*' --http.addr 0.0.0.0 --http.api personal,eth,net,web3 --syncmode light"
networks:
ethereum:
name: ethereum-net
Run Code Online (Sandbox Code Playgroud)
version: "3.5"
services:
eth-server:
container_name: eth_server_dev
build: packages/eth-server/.
environment:
- NODE_ENV=development
- NODE_PORT=3002 …Run Code Online (Sandbox Code Playgroud) 我们正在运行一个 RSK 节点,一些智能合约交易显示内部错误,但与失败require条件相关的消息没有出现在这些错误消息中......
我们只能看到“内部错误”,而无法查看发生了哪个特定错误。
我正在尝试验证使用geth golang库从客户端传入的签名。我正在从一个我的cryptokitties帐户中获取示例数据(签名/地址)(我可以在请求中看到它)。如果我将打击凭据粘贴到https://etherscan.io/verifySig,它将得到验证,因此我知道参数正确。
我的代码:
import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)
sig := 0x80f5bac5b6300ed64835d5e2f167a368c892ccc2d0e252bc84befbcb093f5a2d36294b95d86683cec778c8c796049933c04c71576c56c1d6e9a9fa10342beca31c
data := "Cryptokitties"
decoded = hexutil.MustDecode(sig) // j8aUTtPid0ZnNa/s4Ef5gisYYh1bCeLSmFrtJtDjNRRqxShUr+1A3BVgoAPwiZ+lKN0POB1JOdVhVHI9tcHmABs=
hash := crypto.Keccak256([]byte(data)) // "ljQQTm25oqIbD+LMl70aRUcTzXCeeDGfkRj9YJYsgKY="
pubKey, err := crypto.Ecrecover(hash, sig) // error: "invalid signature recovery id"
Run Code Online (Sandbox Code Playgroud)
我确定我缺少一些简单的东西,但不确定要在哪里看。
**更新
在环顾了一些答案之后我尝试了什么:
像这样更改消息:
fmt.Sprintf("\u0019Ethereum Signed Message:\n%d%s", len(data), data) //"\u0019Ethereum Signed Message:\n13Cryptokitties"
在对消息进行哈希处理之前对消息进行十六进制编码:
data=hexutil.Encode(data)
结合以上两者,因此首先在“以太坊签名消息”之前添加,然后对其进行十六进制编码。
任何观点将不胜感激,我敢肯定这是一个菜鸟问题。
**更新
通过查看源代码,我发现其期望的恢复ID大于4:
sig[64] >= 4
以我为例,结果是27:
sig[64] --> 27
我们正在设置类似于区块链浏览器的东西,但我们的以太坊全节点似乎缺少某些区块的交易信息。
例如,我可以查询eth.getTransaction但eth.getTransactionReceipt返回null
> eth.getTransaction('0x03a05ea076149ae8cff6b0fbc9b1f29c6bf6b7ab04ded92080c54084688456dd')
{
blockHash: "0xfd3b78d9b56e9a911beda3ff488c28c9dd83a9ae4961ba676f852e316cffde89",
blockNumber: 5035686,
from: "0x0ce287cc90601a891e65efda7037f5682cb1ade6",
gas: 210000,
gasPrice: 40000000000,
hash: "0x03a05ea076149ae8cff6b0fbc9b1f29c6bf6b7ab04ded92080c54084688456dd",
input: "0x",
nonce: 21,
r: "0x464f05819d48288db06cac5ff21b49d02a1250df6c4ba1e20ecdb38c558e5b44",
s: "0x1f48c4531a3807b987857b99639b51f54e3718b9f1d808d66ad765ee0f71aba0",
to: "0xe4bad5a72c04d5473e932f54036376772378b83d",
transactionIndex: 72,
v: "0x26",
value: 98082570000000016
}
eth.getTransactionReceipt('0x03a05ea076149ae8cff6b0fbc9b1f29c6bf6b7ab04ded92080c54084688456dd')
null
发生这种情况是否有原因,除了完全重新同步之外还有其他解决方案吗?
我确实相信我第一次同步我使用的区块链--fast,因此可能会错过一些交易,尽管这个参数的记录很少。
使用debug_traceCall时,我可以获得执行期间所有操作码和状态更改的低级 EVM 跟踪。这实在是太详细了。当我使用 default 时callTracer,我可以获得更好的调用树。但是,无论哪种方式,我似乎都无法从跟踪中提取发出的事件。我可以在跟踪(LOG*操作码)中看到它们,但是没有简单的方法可以将它们实际解析为“可读”的东西(以及值和原始地址)必须有一种方法来获取日志 - 有什么想法吗?
例如。这是 Etherscan 显示的https://etherscan.io/tx-decoder?tx=0x3e3ad35fda1fddd9e154b3860b50371a1acd2fdb4f27f897e234846522bde732(请参阅“发出的事件”部分)
geth ×10
ethereum ×7
blockchain ×3
go-ethereum ×3
web3js ×2
debugging ×1
docker ×1
evm ×1
go ×1
javascript ×1
rsk ×1
solidity ×1