13

You don't try to deploy the abstract interface contract IUser. contract User is IUser {} You deploy (migrate) User. Other contracts can use the abstraction to understand the interface to User. User is IUser protects you from certain kinds of developer errors such as failing to define a function in the interface. Hope it helps. Some clarification to ...


12

I had the wrong compiled file selected in the remix "deploy" drop down bar -_- for some reason the default file is the highest one in the hierarchy


4

This is certainly not a code error, not a compiler error. Just proper setting is required on IDE. Just see left hand side, the third tab in 'CONTRACT' section select 'OWNED'


3

Contract ERC20Detailed inherits from interface IERC20, which declares the following functions: function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external ...


2

When using an abstract contract the functions declared in those abstract contracts must always be defined somewhere before they can be used. They can can be defined in 2 places: In another contract already deployed somewhere on the blockchain (which means it will have its own address 0xblahblahblah) and you will need to use that address to instantiate a ...


2

The abstract and virtual keywords signify that the associated code will be implemented or overridden elsewhere in the code. The main difference is that abstract applies to contracts and virtual applies to functions. The purpose of the abstract keyword is to decouple the definition of a contract from its implementation providing better extensibility and self-...


1

You can't create an instance of an abstract contract (with something like Context a = new Context();). So it's probably defined as abstract so it can't be deployed on its own - it has to be inherited. Deploying just the Context contract wouldn't make much sense anyway. Wherever it's in use, it's part of an inheritance.


1

You may need to split the factory up, having one "parent" factory which does not import the contracts, but instead calls one of three factories for the kind of contract being deployed. Then the 3 individual factories each only import one of the contracts, and are only responsible for deploying that one kind of contract. There may also be a way to ...


1

Contracts marked as abstract in Solidity v0.6 and above cannot be initialised. Take the following files: Foo.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.9; contract Foo { function doStuff() external virtual pure returns(string memory) { return "do stuff"; } function doMoreStuff() external virtual pure returns(string memory) { ...


1

Abstract contracts cannot be deployed. Think of them as a blackbox.


1

You are not forced to create and abstract contract to do an implementation. Solidity is not a strongly OOP language, even if something is derived from OOP (interface, inheritance, abstract contracts). So said abstract contracts will give you another level of abstraction and the main reason to use it is to be sure that who implements the contract will follow ...


1

You can create an instance of contract A in contract B and then point that instance to the address of contract A. Deploy contract A: contract A{ struct St{ uint val; } function double(uint a)external returns (uint res){ res= 2*a; } } Now when creating contract B, you can pass the address of contract A. Constructor of B will initialise the ...


1

Using libraries should be able to help somehow. The problem is that from a library function you cannot access the contract state. library Helper { function add(uint x, uint y) internal constant returns (uint) { return x + y; } } contract C { function doSomething(uint x, uint y) public returns (uint) { return Helper.add(uint x, uint y); } }


1

I know this is very old question, but as newer I also faced this problem. // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; abstract contract Feline { function utterance() public virtual returns (bytes32); } according to doc this is way of declaring abstract function.


Only top voted, non community-wiki answers of a minimum length are eligible