我有一份ethers与之进行交易的合同:
const randomSVG = new ethers.Contract(RandomSVG.address, RandomSVGContract.interface, signer)
let tx = await randomSVG.create()
Run Code Online (Sandbox Code Playgroud)
我有一个与此交易有关的事件:
function create() public returns (bytes32 requestId) {
requestId = requestRandomness(keyHash, fee);
emit requestedRandomSVG(requestId);
}
Run Code Online (Sandbox Code Playgroud)
但是,我看不到交易收据中的日志。]( https://docs.ethers.io/v5/api/providers/types/#providers-TransactionReceipt )
// This returns undefined
console.log(tx.logs)
Run Code Online (Sandbox Code Playgroud) 我试图用参数验证我的合同,但收到此错误:
Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed.
Reason: Fail - Unable to verify
Run Code Online (Sandbox Code Playgroud)
我还导入Open Zeppelin合同ERC721Enumerable和Ownable.
这是我的NFTCollectible.sol
pragma solidity 0.8.10;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "hardhat/console.sol";
contract NFTCollectible is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.08 ether;
uint256 public maxSupply = 5000;
uint256 public maxMintAmount = 25;
mapping(address => uint256) public addressMintedBalance;
constructor(
string memory _name,
string memory _symbol, …Run Code Online (Sandbox Code Playgroud) 该代码产生相同的输出。
pragma solidity ^0.5.0;
contract mycontract
{
function add(uint c, uint d) public pure returns(uint)
{ uint e=c+d;
return e;
}
function add(uint j, uint k) public view returns(uint)
{ uint f=j+k;
return f;
}
}
Run Code Online (Sandbox Code Playgroud) functional-programming blockchain ethereum solidity smartcontracts
我正在使用以太坊制作一个项目。
在这个项目中,我正在制定一个名为“A”的合同。
当我向“A”发送消息时,我希望“A”发出网络请求。
Solidity 是否可以使用 http 请求(方法 GET/POST )?
我已经花了几个小时试图了解执行价格。
我理解中间价格的概念,因为它是两对之间的准备金比率。
根据 Uniswap sdk文档,执行价格是发送/接收资产的比率。我很难理解计算是如何完成的。此外,Uniswap 的货币对交换似乎是基于执行价格而不是中间价格。为什么在交易时使用执行价格而不是中间价格?
我正在 Solidity 中学习以太坊开发,并尝试运行一个简单的 HelloWorld 程序,但遇到了以下错误:
函数中返回参数的数据位置必须是“内存”或“calldata”,但没有给出。
我的代码:
pragma solidity ^0.8.5;
contract HelloWorld {
string private helloMessage = "Hello world";
function getHelloMessage() public view returns (string){
return helloMessage;
}
}
Run Code Online (Sandbox Code Playgroud) 在尝试建立一个基本的自托管单元测试环境(和 CI)来测试这个 Chainlink VRF 随机数合约时时,我在如何在本地模拟任何相关的区块链/测试网方面遇到了一些困难。
\n例如,我发现这个测试 Chainlinks VRF 的存储库。但是,对于默认部署,它建议/需要免费,KOVAN_RPC_URL例如来自 Infura 的站点,甚至对于“本地部署”,它建议/需要免费MAINNET_RPC_URL例如来自 Alchemy 的站点。
我采用了waffle框架的单元测试环境,描述如下:
\nsrc____AmIRichAlready.sol\n |____RandomNumberConsumer.sol\n |\ntest____AmIRichAlready.test.ts\n |____mocha.opts\npackage.json\ntsconfig.json\nwaffle.json\nyarn.lock\nRun Code Online (Sandbox Code Playgroud)\nAmIRichAlready.sol
\npragma solidity ^0.6.2;\n\ninterface IERC20 {\n function balanceOf(address account) external view returns (uint256);\n}\n\ncontract AmIRichAlready {\n IERC20 private tokenContract;\n uint public richness = 1000000 * 10 ** 18;\n\n constructor (IERC20 _tokenContract) public {\n tokenContract = _tokenContract;\n }\n\n function check() public view returns …Run Code Online (Sandbox Code Playgroud) 我试图遵循devto.io的教程并将交易发送到智能合约,我需要使用运行npx hardhat node命令时创建的帐户之一连接我的 MetaMask 钱包。为此,我打开 MetaMask 并将网络更新为 Localhost 8545,但 Metamask 未连接到它并显示如下屏幕截图所示的错误。

我很难理解为什么以及何时在 NFT 生成合约上调用 SetApprovalForAll。
以酷猫为例。为了方便起见,下面有相关交易的屏幕截图。
我注意到,对于此合同和其他合同,反复调用“Set Approval For All”。根据我自己对允许铸造的合约的有限经验,via _safeMint,我也在日志中看到了 SetApprovalForAll 交易。它没有在我的代码中直接调用。
为什么这么称呼它?钱包是否将其作为铸造过程的一部分?
我在编译时遇到此错误。我知道它与 v8 有关,我需要让他们付费,我做到了,但仍然不起作用。好心人能帮忙吗?
contract FundMe {
mapping(address =>uint256) public addressToAmountFunded;
address payable[] public funders;
address payable public owner;
constructor() public {
owner = msg.sender; //LINE WITH ERROR
}
function fund() public payable {
uint256 minimumUSD = 50 * 10 ** 18;
require(getConversionRate(msg.value) >= minimumUSD, "you need to spend more ETH my friend");
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender); //ERROR AS WELL
}
Run Code Online (Sandbox Code Playgroud) solidity ×10
ethereum ×6
blockchain ×3
ethers.js ×2
hardhat ×2
openzeppelin ×2
chainlink ×1
erc721 ×1
etherscan ×1
ganache ×1
http ×1
javascript ×1
metamask ×1
nft ×1
random ×1
request ×1
unit-testing ×1