标签: blockchain

web3.js 如何搜索所有曾经创建的合约并查看地址

我是 web3.js 和 Solidity 的新手。我的问题与我们在区块链上搜索的方式有关。如果我们知道合约地址,就很容易搜索特定合约。然而,我们如何使用最初用于创建合约的地址来查找和识别特定类型的合约。

例如。我有一个合同 ContractA,它是由“发件人”地址 AddressA 使用 web3.js 创建的。现在我想找到由AddressA创建的ContractA的所有实例。

我尝试使用 web3.eth.filter API 进行搜索,但注意到没有返回。请帮忙。

我还阅读了有关使用注册表模式来存储所有合同并询问注册表的信息,但找不到任何有用的示例。

blockchain ethereum solidity web3js

4
推荐指数
1
解决办法
3966
查看次数

如何发送wei/eth到合约地址?(使用truffle javascript测试)

我正在尝试将 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)

testing blockchain ethereum solidity truffle

4
推荐指数
1
解决办法
8829
查看次数

Solidity:ParserError:预期的编译指示、导入指令或合约/接口/库定义

当我编写简单合约时,我也遇到了最新的 solc(0.5.2 版本)和 0.4.25 的错误

我尝试过以下步骤

  1. 已卸载的 Solc: npm uninstall solc
  2. 安装的目标版本: npm install --save solc@0.4.25
  3. 节点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)

node.js blockchain ethereum solidity smartcontracts

4
推荐指数
1
解决办法
2万
查看次数

General Question on how to use Quorum blockchain

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 …

blockchain ethereum solidity quorum

4
推荐指数
1
解决办法
1000
查看次数

如何将TRON地址转换为不同格式

我在 TRON 网络中部署合约时遇到问题,需要以 4.. 开头的格式指定地址,或者当我收到交易历史记录时(此处 api 也以 4.. 地址响应)。

因此我有一个问题:

如何将以T LAXtqju7GKyqoP... 开头的 TRON 地址转换为4 19b6e043089843624c36f1e3b1e8572d189cbe170 ,反之亦然?

blockchain tron

4
推荐指数
1
解决办法
2万
查看次数

Hypererdger Indy 节点 - 种子值

我正在使用 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 中没有有关此特定值的信息。

我的问题是我们如何知道这是正确的值以及如何获得它?

blockchain hyperledger hyperledger-indy

4
推荐指数
1
解决办法
2431
查看次数

有没有办法让区块链上的某一特定信息只能由一个特定账户查询?

只是想知道,有没有办法让区块链上的特定信息只能由一个特定账户查询?

更确切地说,我正在考虑让用户将他们的信息放在链上并授予特定帐户访问权限,这样只有该帐户才能从链上查询该信息。

我检查了ZK-SNARK,似乎这个算法只是为了验证信息是否正确,而不知道信息的任何细节。好像在这种情况下不能使用

blockchain ethereum zcash substrate

4
推荐指数
1
解决办法
153
查看次数

Metamask 停止注入 web3.js

据我们所知,从2020年1月13日开始,metamask将不再注入web3.js。我们应该采取哪些方法来停止对web3的依赖?

另外,我们如何使用目前正在注入 web3.js 的现有 Metamask 来测试它。

blockchain ethereum web3js metamask decentralized-applications

4
推荐指数
1
解决办法
7205
查看次数

通过 WSS 连接到本地网络上运行的 Polkadot Full Noder 失败

我已经设置了一个在 192.168.2.254 的本地服务器上运行的完整节点。我只是想制作一个简单的脚本,基本上是订阅区块链上的新头。

\n
const { 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);\n
Run Code Online (Sandbox Code Playgroud)\n

在服务器上,我还按照 Polkadot wiki 的建议使用自签名 ssl 证书设置了 nginx。这是块配置:

\n
server {\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)

blockchain cryptocurrency substrate polkadot-js polkadot

4
推荐指数
1
解决办法
1922
查看次数