[英]Chainlink.Request doesn't have `add` function
Now I am using this dependency: "@chainlink/contracts": "^0.1.7"
and solc v0.8现在我正在使用这个依赖项:
"@chainlink/contracts": "^0.1.7"
0.1.7 "@chainlink/contracts": "^0.1.7"
和 solc v0.8
Facing this issue: Member "add" not found or not visible after argument-dependent lookup in struct Chainlink.Request memory
面临这个问题:
Member "add" not found or not visible after argument-dependent lookup in struct Chainlink.Request memory
It's saying that Chainlink.Request
doesn't have add
function... please let me know how to fix it.据说
Chainlink.Request
没有add
功能...请告诉我如何修复它。
...
import "@chainlink/contracts/src/v0.8/dev/ChainlinkClient.sol";
contract ContractName is Ownable, ChainlinkClient {
constructor() {
setPublicChainlinkToken();
}
function requestData(
address _oracle,
bytes32 _jobId,
string memory _endpoint,
string memory _round,
string memory _seasonId
) public {
Chainlink.Request memory req =
buildChainlinkRequest(_jobId, address(this), this.fulfill.selector);
req.add(req, "endpoint", _endpoint);
req.add(req, "round", _round);
req.add(req, "season_id", _seasonId);
sendChainlinkRequestTo(_oracle, req, fee_);
}
Edit: Always be weary of contracts still in the dev branch.编辑:总是对仍在开发分支中的合同感到厌烦。 With that being said, v0.8 Chainlink Client is now out of the dev branch and this answer is still relevant.
话虽如此,v0.8 Chainlink Client 现在不在 dev 分支中,这个答案仍然相关。
I ran into the same issue and contacted Avneet from the Chainlink team.我遇到了同样的问题,并联系了 Chainlink 团队的 Avneet。 Turns out this is caused by a change in the Solidity language starting from v0.7:
原来这是由从 v0.7 开始的 Solidity 语言的变化引起的:
Breaking change in v0.7:
v0.7 中的重大变化:
using A for B only affects the contract it is mentioned in. Previously, the effect was inherited.
对 B 使用 A 只会影响它提到的合约。以前,效果是继承的。 Now, you have to repeat the using statement in all derived contracts that make use of the feature.
现在,您必须在所有使用该功能的派生合约中重复 using 语句。 https://docs.soliditylang.org/en/v0.7.0/070-breaking-changes.html
https://docs.soliditylang.org/en/v0.7.0/070-break-changes.html
Therefore, you need to add using Chainlink for Chainlink.Request;
因此,需要
using Chainlink for Chainlink.Request;
添加using Chainlink for Chainlink.Request;
to the top of your contract, like so:到合同的顶部,如下所示:
contract MyClient {
using Chainlink for Chainlink.Request;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.