我无法迁移松露编译带来的标准合同.这是我做的:
truffle init
truffle compile
open other terminal and run testrpc
truffle migrate
Run Code Online (Sandbox Code Playgroud)
并且前三步是平稳操作,但是当我运行松露迁移时,它会出现
Error: No network specified. Cannot determine current network.
at Object.detect (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43157:23)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:200497:19
at finished (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43085:9)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:198408:14
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:68162:7
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:163793:9
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:160353:16
at replenish (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:160873:25)
at iterateeCallback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:160863:17)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:160838:16
Run Code Online (Sandbox Code Playgroud)
我的版本列表:
node 9.1.0
truffle 4.0.1
testrpc 6.0.3
Run Code Online (Sandbox Code Playgroud)
谢谢!
在javascript中我运行契约的方法
contract[methodName](...params, { from: myAccount }, (err, response) => {
console.log('get transaction', methodName, err, response);
if (err) return reject(err);
resolve(response);
});
Run Code Online (Sandbox Code Playgroud)
然后通过MetaMask拒绝交易.在控制台中出错
MetaMask - RPC Error: Error: MetaMask Tx Signature: User denied transaction signature.
Run Code Online (Sandbox Code Playgroud)
但我无法在我的代码中发现此错误.回调不起作用.
我怎样才能在JS中发现这个错误?
我想从账户A在以太坊进行交易,但交易费用应该从账户B支付。在以太坊可以吗?
我尝试为使用 bitcoinj 库实现的 HD 钱包密钥生成以太坊地址,但我感到困惑:
DeterministicSeed seed = new DeterministicSeed("some seed code here", null, "", 1409478661L);
DeterministicKeyChain chain = DeterministicKeyChain.builder().seed(seed).build();
DeterministicKey addrKey = chain.getKeyByPath(HDUtils.parsePath("M/44H/60H/0H/0/0"), true);
System.out.println("address from pub=" + Keys.getAddress(Sign.publicKeyFromPrivate(addrKey.getPrivKey())));
Run Code Online (Sandbox Code Playgroud)
此代码根据https://iancoleman.io/bip39/打印正确的以太坊地址。这里一切都很好。
但是,当我尝试避免使用私钥并使用公钥生成非强化密钥时,我只会得到不同的结果,即调用返回另一个结果:
System.out.println("address from pub=" + Keys.getAddress(addrKey.getPublicKeyAsHex()));
Run Code Online (Sandbox Code Playgroud)
看起来问题出在“不同的公钥”上,即Sign.publicKeyFromPrivate(addrKey.getPrivKey())和 的结果addrKey.getPublicKeyAsHex()是不同的。我对密码学没有经验,因此这可能是一个愚蠢的问题......但我会很感激这里的任何建议。
我是区块链新手。
我做了一些研究,以下是我使用 web3.js 获取某个钱包拥有的 NFT 列表的步骤
balance = ERC721.methods.balanceOf(walletAddress).call();
objects = [];
for (i = 0; i < balance; i++) {
tokens.push(await ERC721.methods.tokenOfOwnerByIndex(walletAddress, i).call());
}
for(i = 0; i < tokens.length; i++){
objects.push(await ERC721.methods.tokenURI(tokenIdList[i]).call());
}
Run Code Online (Sandbox Code Playgroud)
我可以使用上述方法获取 ERC721 令牌 URI 列表,但性能非常差。我想知道 OpenSeas 如何在相同功能上以光速性能实现这一目标。
我一直在尝试按照web3-react的文档集成WalletConnect。
我用于连接器的配置如下:
import { WalletConnectConnector } from '@web3-react/walletconnect-connector';
export const walletconnect = new WalletConnectConnector({
rpc: { 1: RPC_URLS[1], 4: RPC_URLS[4] },
infuraId: INFURA_TOKEN,
bridge: BRIDGE_URL,
qrcode: true,
pollingInterval: 15000,
});
Run Code Online (Sandbox Code Playgroud)
另外,软件包的版本如下:
"@web3-react/core": "^6.0.9",
"@web3-react/walletconnect-connector": "^6.2.0",
Run Code Online (Sandbox Code Playgroud)
当我使用以下代码中解释的activate函数时:useWeb3React()
const { connector, activate, active, account } = useWeb3React();
Run Code Online (Sandbox Code Playgroud)
activate(walletconnect, undefined, true)
.catch((error) => {
if (error instanceof UnsupportedChainIdError) {
activate(walletconnect)
} else {
console.log('Pending Error Occured')
}
})
Run Code Online (Sandbox Code Playgroud)
它能够生成二维码,我也能够成功扫描手机上的 MetaMask 应用程序,并在移动应用程序上显示已成功连接。
不过,在 Web 应用程序的控制台日志上,它显示一条警告:
Warning: …Run Code Online (Sandbox Code Playgroud) 我需要为我的宠物项目测试以太坊。
我访问https://faucet.rinkeby.io/,在 MetaMask 中添加我的推文链接以及我的以太坊地址,然后选择3 Ethers / 8 hours。
请求已接受,但 17 小时过去了,我还没有收到测试以太币。
是我出了什么问题还是我必须再等一会儿?请解释一下,3 以太/8 小时到底意味着什么?
我尝试更改令牌基本 URL 以在 opensea.io 上显示 NFT 的新图像。但不会立即更新。
有一种方法可以通过在 Rikeby 测试网上指定force_update=true 来进行更新。
但我不知道如何在主网上更新它。有可能吗?
任何帮助将不胜感激。
使用 web3 (python3) 我正在尝试解码 BSC 交易的输入数据,如 BscScan 上所示

在一些解决方案中,我发现正在使用以下代码:
import web3
from web3.contract import Contract
...
contract = web3.eth.contract(address=Web3.toChecksumAddress(tokenAddress), abi=abi)
contract.functions.decode_function_input(transaction.input)
Run Code Online (Sandbox Code Playgroud)
但是,abi 似乎没有定义此函数“decode_function_input”,因为我收到错误:
"web3.exceptions.ABIFunctionNotFound: ("The function 'decode_function_input' was not found in this contract's abi. ", 'Are you sure you provided the correct contract abi?')"
Run Code Online (Sandbox Code Playgroud)
我 100% 认为 abi 是正确的。此外,在 BscScan 合约原始视图中,函数“decode_function_input”确实不存在。
还有其他解决方案,如何解码输入数据?
我想在 RSK 和以太坊中构建一个每年支付股息的 Solidity 智能合约。假设 RSK 和以太坊当前的平均块间时间,我应该使用块时间还是可以依赖块编号?
ethereum ×10
blockchain ×3
javascript ×2
web3-java ×2
web3js ×2
bitcoinj ×1
cryptography ×1
evm ×1
geth ×1
ipfs ×1
java ×1
metadata ×1
metamask ×1
nft ×1
node.js ×1
opensea ×1
python ×1
python-3.x ×1
reactjs ×1
rsk ×1
solidity ×1
truffle ×1
web3-react ×1
web3py ×1