0

I have issues so I slowly add one library at a time. This code compiles.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

contract TestContract is ReentrancyGuard, Ownable(msg.sender) {}

The Stack trace

$ npx hardhat compile --show-stack-traces
Generating typings for: 1 artifacts in dir: typechain-types for target: ethers-v6
Successfully generated 16 typings!
Compiled 1 Solidity file successfully

But this code fails

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";
import "@balancer-labs/v2-interfaces/contracts/vault/IFlashLoanRecipient.sol";

contract TestContract is
    IFlashLoanRecipient,
    ReentrancyGuard,
    Ownable(msg.sender)
{
    function receiveFlashLoan() external {
        uint test = 123;
    }
}

And the stack trace:

$ npx hardhat compile --show-stack-traces
deployerWallet.address: 0x6B25765E09a303294649A190C436e3317C2FA56B
TypeError: Contract "TestContract" should be marked as abstract.
 --> contracts/TestContract.sol:9:1:
  |
9 | contract TestContract is
  | ^ (Relevant source part starts here and spans across multiple lines).
Note: Missing implementation: 
  --> @balancer-labs/v2-interfaces/contracts/vault/IFlashLoanRecipient.sol:31:5:
   |
31 |     function receiveFlashLoan(
   |     ^ (Relevant source part starts here and spans across multiple lines).


Error HH600: Compilation failed

HardhatError: HH600: Compilation failed
    at SimpleTaskDefinition.action (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/builtin-tasks/compile.ts:474:15)
    at async Environment._runTaskDefinition (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async OverriddenTaskDefinition._action (/home/user/Documents/crypto-projects/pigfox/node_modules/@typechain/hardhat/src/index.ts:28:30)
    at async Environment._runTaskDefinition (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async Environment.run (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at async SimpleTaskDefinition.action (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/builtin-tasks/compile.ts:1352:63)
    at async Environment._runTaskDefinition (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at async Environment.run (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at async SimpleTaskDefinition.action (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/builtin-tasks/compile.ts:1432:7)
    at async Environment._runTaskDefinition (/home/user/Documents/crypto-projects/pigfox/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)

1 Answer 1

1

It simply means that you are not implementing all functions of an Interface.

When a contract inherits other contracts, functions are already declared and are inherited, however when inheriting an interface the functions of an interface only have the function headers and need to be declared in the inheriting contract.

If you do not wish to implement them all and only wish to use this contract to declare some functions but not all, then you can declare your contract as abstract. However an abstract contract is not deployable as is, since all functions should end up being implemented by the final deployed contract.


In conclusion, find the functions you are not implementing and implement them !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.