我是 web3.js 和 Solidity 的新手。我的问题与我们在区块链上搜索的方式有关。如果我们知道合约地址,就很容易搜索特定合约。然而,我们如何使用最初用于创建合约的地址来查找和识别特定类型的合约。
例如。我有一个合同 ContractA,它是由“发件人”地址 AddressA 使用 web3.js 创建的。现在我想找到由AddressA创建的ContractA的所有实例。
我尝试使用 web3.eth.filter API 进行搜索,但注意到没有返回。请帮忙。
我还阅读了有关使用注册表模式来存储所有合同并询问注册表的信息,但找不到任何有用的示例。
我正在尝试将 wei/eth 发送到我的 Solidity 合约的地址,该合约具有外部应付回退功能。我下面的 truffle javascript 测试不会导致 instance.address 的余额获得任何 wei。instance.address不是接收wei的智能合约地址吗?有人能发现为什么 console.logging 余额结果为 0 吗?或者发现我错过了什么?
谢谢!
const TestContract = artifacts.require("TestContract");
contract('TestContract', async (accounts) => {
it('should send 1 ether to TestContract', async () => {
let instance = await TestContract.deployed();
instance.send({from: accounts[1], value: 1000000000000000000});
let balance = await web3.eth.getBalance(instance.address);
console.log('instance.address balance: ' + parseInt(balance));
)}
Run Code Online (Sandbox Code Playgroud) 当我编写简单合约时,我也遇到了最新的 solc(0.5.2 版本)和 0.4.25 的错误
我尝试过以下步骤
节点compile.js(代码如下)
{ contracts: {},
errors:
[ ':1:1: ParserError: Expected pragma, import directive or contract
/interface/library definition.\nD:\\RND\\BlockChain\\contracts\\Inbox.sol\n^\n' ],sourceList: [ '' ],sources: {} }
Run Code Online (Sandbox Code Playgroud)编译.js
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const inPath = path.resolve(__dirname,'contracts','Inbox.sol');
const src = fs.readFileSync(inPath,'UTF-8');
const res = solc.compile(inPath, 1);
console.log(res);
Run Code Online (Sandbox Code Playgroud)
收件箱.sol
pragma solidity ^0.4.25;
contract Inbox {
string message;
function Inbox(string passedName) public {
message …Run Code Online (Sandbox Code Playgroud) I am very new to quorum programming. I already made some Smart Contracts with solidity on ethereum and made some dapps with Truffle, React and Metamask.
Now I did this Quorum Tutorial: https://truffleframework.com/tutorials/building-dapps-for-quorum-private-enterprise-blockchains
Before I get to the problem I have, I tell you what I am trying to do: Right now we have a database in our school, where the teacher can save the marks of the students, and the students can log in and see the marks they …
我在 TRON 网络中部署合约时遇到问题,需要以 4.. 开头的格式指定地址,或者当我收到交易历史记录时(此处 api 也以 4.. 地址响应)。
因此我有一个问题:
如何将以T LAXtqju7GKyqoP... 开头的 TRON 地址转换为4 19b6e043089843624c36f1e3b1e8572d189cbe170 ,反之亦然?
我正在使用 indy-sdk 并在步骤 3 中的演练演示中(https://github.com/hyperledger/indy-sdk/blob/master/docs/getting-started/indy-walkthrough.md#step-3-getting -the-ownership-for-stewards-verinym)Steward 集的种子值等于“000000000000000000000000Steward1”。
如果我更改它(或将其留空),我会收到错误。此外,在 /tmp/indy/poo1.txn 中没有有关此特定值的信息。
我的问题是我们如何知道这是正确的值以及如何获得它?
只是想知道,有没有办法让区块链上的特定信息只能由一个特定账户查询?
更确切地说,我正在考虑让用户将他们的信息放在链上并授予特定帐户访问权限,这样只有该帐户才能从链上查询该信息。
我检查了ZK-SNARK,似乎这个算法只是为了验证信息是否正确,而不知道信息的任何细节。好像在这种情况下不能使用
据我们所知,从2020年1月13日开始,metamask将不再注入web3.js。我们应该采取哪些方法来停止对web3的依赖?
另外,我们如何使用目前正在注入 web3.js 的现有 Metamask 来测试它。
blockchain ethereum web3js metamask decentralized-applications
我已经设置了一个在 192.168.2.254 的本地服务器上运行的完整节点。我只是想制作一个简单的脚本,基本上是订阅区块链上的新头。
\nconst { ApiPromise, WsProvider } = require(\'@polkadot/api\');\n\nasync function main () {\n const wsProvider = new WsProvider(\'wss://192.168.2.254:9944\');\n const api = await ApiPromise.create({ provider: wsProvider });\n\n let count = 0;\n\n const unsubscribe = await api.rpc.chain.subscribeNewHeads((header) => {\n console.log(`Chain is at block: #${header.number}`);\n\n if (++count === 256) {\n unsubscribe();\n process.exit(0);\n }\n });\n}\n\nmain().catch(console.error);\nRun Code Online (Sandbox Code Playgroud)\n在服务器上,我还按照 Polkadot wiki 的建议使用自签名 ssl 证书设置了 nginx。这是块配置:
\nserver {\n server_name 192.168.2.254\n\n root /var/www/html;\n index index.html;\n\n location / {\n try_files $uri $uri/ =404;\n\n proxy_pass http://localhost:9944;\n proxy_set_header …Run Code Online (Sandbox Code Playgroud) 我想找到所有有索引或已注册身份的 polkadot 帐户;类似于https://polkascan.io/polkadot/account/identities和https://polkascan.io/polkadot/indices/account。
blockchain ×10
ethereum ×6
solidity ×4
substrate ×3
polkadot ×2
web3js ×2
hyperledger ×1
metamask ×1
node.js ×1
polkadot-js ×1
quorum ×1
testing ×1
tron ×1
truffle ×1
zcash ×1