0

I'm trying to write my first smart contract but when I try to deploy it I get this:

This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly.

I would really appreciate it if anyone could take a look at my code. Thanks so much in advance. This is my code:

// SPDX-License-Identifier: MIT pragma solidity =0.5.16; import "https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2ERC20.sol"; contract AkalinsToken is UniswapV2ERC20{ string public constant name = "Akalins Token"; string public constant symbol = "AKALIN"; } 
1
  • Hi, what is your end goal? Deploy an ERC-20 token? This code seems quite outdated; Solidity is now on V0.8. I should be able to guide you once I know what your goal is! Commented May 16, 2024 at 19:08

2 Answers 2

0

I tried to deploy the contract at my side it's working fine. Just make sure to select the AkalinsToken - Abstract.sol contract before clicking on deploy button as in this picture: enter image description here

After setting that when you will click on deploy button it will deploy. enter image description here

0

This error means that there are functions that are not implemented in your smart contract.

In Solidity you can inherit an other smart Contract, meaning another smart contract is written with functions and by inheriting from it you can use its function, without writing extra code.

However sometimes in a contract the functions are not implemented. Only the header of the function is defined, but its core logic is not written. The child contract has to implement every function to be able to be deployed.

That can come from 3 inherited sources:

  • an Interface

  • an Abstract Contract

  • a constructor of a parent contract that is not implemented in the child contract.

=> An Interface is a contract where no functions are implemented. Only the header of the functions are written. It serves as a guideline to show which function should be present in the child contract to respect a certain set of functionalities. However how the function is implemented is generally left to the developer, that can innovate !

=> An Abstract contract is a contract where some functions but not all are implemented.

=> a Constructor is a special function only defined once per contract that will be called only once in the lifetime of a smart contract, during its initial deployment. It takes in certain parameters, that will define certain variables at deployment.


In conclusion:

All functions of parent contracts that are not implemented should be implemented in the child contract.

  • For unimplemented Interface or Abstract contract: write the function header and then write the function logic inside the function. (You may have to use the override command)

  • For an unimplemented constructor, you have two ways to implement it in the child contract:

     contract myContract is ParentContract([parameter1],[parameter2]) { ... } 

or

constructor(uint256 [parameter1], uint256[parameter2]) ParentContract([parameter1],[parameter2]){ ...} 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.