我有一个问题:我应该选择哪个提供商来与主网上的合约进行交互,为什么?
看起来 Web3Provider 更容易使用,有什么缺点吗?
谢谢您的回答。
我试图从 FTM 网络上的智能合约调用名为“remove_liquidity_one_coin”的函数,但出现以下错误并且无法找出原因:
TypeError: curveContract.remove_liquidity_one_coin is not a function
通常,当我想要调用合约的函数时,我会获取 ABI(合约地址),然后实例化它并可以使用它的函数。
对于下面的合约,它适用于“读取”功能,但不适用于“写入”功能,例如remove_liquidity_one_coin.
这是我使用的简化代码:
let signer = new ethers.Wallet(privateKey, provider)
let contractAddress = "0xa58f16498c288c357e28ee899873ff2b55d7c437"
let contractAbi = [...] // ABI of the contract. In this case: https://api.ftmscan.com/api?module=contract&action=getabi&address=0x3cabd83bca606768939b843f91df8f4963dbc079&format=raw
let curveContract = new ethers.Contract(contractAddress, contractAbi, signer)
// Read function => works
let liquidityToRemove = await curveContract.calc_withdraw_one_coin(
lpTokenToWidraw, // Amount to withdraw
0 // Index of the token to withdraw
);
// Write function => doesn't work
let receivedCoins = await curveContract.remove_liquidity_one_coin( …Run Code Online (Sandbox Code Playgroud) 我正在尝试调试和测试我开发的智能合约,但是在测试网上这样做需要花费大量时间,而且我想在本地节点上正确测试。
我可以创建节点并部署合约,从元掩码中的帐户转移到另一个帐户,一切正常,除了当我在浏览器中访问http://127.0.0.1:8545/时 ,我收到此错误:
{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error: Unexpected end of JSON input"}}
Run Code Online (Sandbox Code Playgroud)
我尝试过勇敢和镀铬,我尝试创建一个不同的安全帽项目,同样的错误。
我能做些什么?谢谢!
SOlidity 课程:Brownie Fund Me 第 6 课:https://github.com/PatrickAlphaC/brownie_fund_me
编译 AggregatorV2V3Interface 会导致 TypeError:接口无法继承。接口我在contract->test下添加了一个文件MockV3Aggregator.sol来部署模拟。但是,当我使用“browniecompile”时,出现以下错误:
PS C:\Users\user\Documents\BC\demos\brownie_fund_me> brownie compile
INFO: Could not find files for the given pattern(s).
Brownie v1.18.1 - Python development framework for Ethereum
Compiling contracts...
Solc version: 0.6.0
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
C:/Users/user/.brownie/packages/smartcontractkit/chainlink-brownie-
contracts@1.1.1/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:38:
TypeError: Interfaces
cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-----------------^
C:/Users/user/.brownie/packages/smartcontractkit/chainlink-brownie-
contracts@1.1.1/contracts/src/v0.6/interfaces/AggregatorV2V3Interface.sol:7:59:
TypeError: Interfaces
cannot inherit.
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
^-------------------^
Run Code Online (Sandbox Code Playgroud) 当我编写代码时,我在代码的第 10 行收到警告。谁能告诉我这个警告是什么意思?
我的代码
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.5.0 < 0.9.0;
contract PracticeTest // It's a class
{
string name ;
uint256 age;
constructor() public
{
name = "Ali";
age = 21 ;
}
}
Run Code Online (Sandbox Code Playgroud)
这是警告
Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> contracts/PracticeTest.sol:10:5:
|
10 | constructor() public
| ^ (Relevant source part starts here and spans across multiple lines).
Run Code Online (Sandbox Code Playgroud) 我的 bin 文件大小只有 18kb。我还得到了使用 IPFS 的解决方案,但不知道如何使用它。如果有任何使用 IPFS 的参考,请分享给我。:
错误:PrecheckStatusError:事务 0.0.34898094@1653658245.135892060 预检查失败,状态为 TRANSACTION_OVERSIZE
这是我的代码:
const {
AccountId,
PrivateKey,
Client,
FileCreateTransaction,
ContractCreateTransaction,
ContractFunctionParameters,
ContractExecuteTransaction,
ContractCallQuery,
Hbar
} = require("@hashgraph/sdk");
const fs = require("fs");
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_PVKEY);
const client = Client.forTestnet().setOperator(operatorId, operatorKey);
async function main() {
// Import the compiled contract bytecode
const contractBytecode = fs.readFileSync("first_contract_sol_ABC_TOKEN.bin");
// Create a file on Hedera and store the bytecode
const fileCreateTx = new FileCreateTransaction().setContents(contractBytecode).setKeys([operatorKey]).setMaxTransactionFee(new Hbar(1))
.freezeWith(client);
const fileCreateSign = await fileCreateTx.sign(operatorKey); …Run Code Online (Sandbox Code Playgroud) 我是 solana 的新手,正在探索 solana 的 web3js 部分。我偶然发现了“时代”这个词。我知道我们通常使用的时间戳是什么纪元。但在 solana 中,纪元的定义却截然不同。我阅读了官方文档,但无法正确理解纪元的含义。谁能解释一下 solana 中的纪元到底是什么?
我正在尝试在debian 8上安装Open Transactions,这是一个开源项目.我已经安装了所有的依赖项,并且在编译(make)时遇到了问题.我的终端显示以下错误,即使我确保安装了protobuf项目:
In file included from /root/opentxs/src/../include/opentxs/core/OTStoragePB.hpp:64:0,
from /root/opentxs/src/core/OTStorage.cpp:47:
/root/opentxs/build/src/core/otprotob/Generics.pb.h:501:6: error: "PROTOBUF_INLINE_NOT_IN_HEADERS" is not defined [-Werror=undef]
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
^
In file included from /root/opentxs/src/../include/opentxs/core/OTStoragePB.hpp:65:0,
from /root/opentxs/src/core/OTStorage.cpp:47:
/root/opentxs/build/src/core/otprotob/Markets.pb.h:2062:6: error: "PROTOBUF_INLINE_NOT_IN_HEADERS" is not defined [-Werror=undef]
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
^
In file included from /root/opentxs/src/../include/opentxs/core/OTStoragePB.hpp:66:0,
from /root/opentxs/src/core/OTStorage.cpp:47:
/root/opentxs/build/src/core/otprotob/Bitcoin.pb.h:833:6: error: "PROTOBUF_INLINE_NOT_IN_HEADERS" is not defined [-Werror=undef]
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
^
In file included from /root/opentxs/src/../include/opentxs/core/OTStoragePB.hpp:67:0,
from /root/opentxs/src/core/OTStorage.cpp:47:
/root/opentxs/build/src/core/otprotob/Moneychanger.pb.h:1026:6: error: "PROTOBUF_INLINE_NOT_IN_HEADERS" is not defined [-Werror=undef]
#if !PROTOBUF_INLINE_NOT_IN_HEADERS
^
cc1plus: all warnings being treated as errors
src/core/CMakeFiles/opentxs-core.dir/build.make:1368: recipe …Run Code Online (Sandbox Code Playgroud) 今天可以将作曲家结构业务网络.bna文件部署到bluemix区块链服务吗?如果是,是否有人可以共享的连接配置文件示例?谢谢.