Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [constructor]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
23 views

How do I determine the constructor bytecode for contracts created by another contract

I am looking to decode constructor arguments for EVM contracts. Some contracts are created by externally owned accounts, but many are created via a contract transaction. In both cases how can I ...
Matthew's user avatar
0 votes
0 answers
13 views

How to solve constructor params missing issue?

This is my constructor code for the trading receiver constructor(address _staking, address _trading, address _lzEndpoint) NonblockingLzApp(_lzEndpoint) { liquidityI = ...
Vinit_2311's user avatar
1 vote
2 answers
29 views

Assigning the owner variable outside of constructor or function

How is assigning a variable outside of a constructor or a function legit? contract A { address public immutable OWNER = msg.sender; }
Ougi's user avatar
  • 25
1 vote
1 answer
21 views

Meaning of msg.sender in constructor

What is the meaning of a msg.sender in a constructor? Is it strictly the owner of a contract or any EOA account calling the contract?
Jayman's user avatar
  • 13
1 vote
2 answers
79 views

Verification of a proxy contract not working because of constructor args

I am creating a smart contract verification service as a learning experiment and I am now able to verify most of contracts that I come across etherScan (in part doing so there is not only an option). ...
Daniel Pérez García's user avatar
2 votes
1 answer
361 views

Beacon contract contructor seems to call address 0x02?

The Beacon (Eth 2.0 deposit) contract was once deployed using a certain (constructor) script, like every other contract on the EVM blockchain. While analyzing that constructor script, it seems that it ...
Albert Hendriks's user avatar
0 votes
0 answers
31 views

creation of PairFlash errored: Error encoding arguments: Error: types/values length mismatch (count={"types":5,"values":11

Getting this error when attempting to deploy a contract that reads in three addresses and two tuples creation of PairFlash errored: Error encoding arguments: Error: types/values length mismatch (count=...
user avatar
0 votes
1 answer
35 views

Understanding the Purpose of 'revert' Statement in Constructor of Account Abstraction Repo

I'm using the bundler repo, and during a code review, I'm having trouble understanding why the revert is used in the constructor. The intention seems to be to trigger an error, but using revert in ...
Soham malve's user avatar
2 votes
2 answers
72 views

Solidity Proxy: why using initialiser instead of a constructor?

Why proxies can't read from the constructor?
Dakata's user avatar
  • 225
0 votes
0 answers
183 views

TypeError: AbiCoder is not a constructor, testing purchaseSnack function is failing. I think due to not handling ether conversion correctly

I am trying to write a test script using hardhat to test the purchaseSnack function but I keep receiving these errors. 1) VendingMachine Should fail if insufficient funds are sent: ...
Daryle's user avatar
  • 1
0 votes
1 answer
14 views

Question about Ethernaut Telephone question. Creating attack method instead of using constructor

This is entire contract for the ethernaut Telephone question. I created attack() function, but a youtuber suggests constructor(). Anyone knows why?
Wonjae Choi's user avatar
0 votes
1 answer
39 views

Incorrect use of constructor

I cannot get my code to compile under 0.8.18. I get the error: Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is ...
Philip Rutovitz's user avatar
0 votes
0 answers
60 views

Constructor Arguments for verification on Etherscan

I want to verify a contract on Etherscan.io, but I am not able to find the correct Constructor Arguments. I tried everything which is explained on StackExchange, but cannot get it to verify... using ...
jerry12345's user avatar
0 votes
1 answer
57 views

How to find Constructor Arguments for verification on Etherscan.io

I spent 4 days for this work. plz make me know anybody. this is solidity code of my token I use openzeppelin. // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/...
jerry12345's user avatar
1 vote
1 answer
40 views

Using inherited constructors with a proxy factory

I am attempting to use Chainlink VRF along with OpenZeppelin's upgradable contracts to generate a random number. In order to use VRF, I must inherit the constructor from VRFV2WrapperConsumerBase. ...
root's user avatar
  • 11
0 votes
1 answer
170 views

Can't create UniswapV2Pair from constructor on Ethereum Mainnet

I want to create a Uniswap Pair in a constructor() block of my token smart-contract. However, when I try to do this, I get "error":"execution reverted". Perhaps these nuances will ...
ppduster's user avatar
0 votes
2 answers
107 views

Constructor Inheritance: : Wrong argument count for constructor call

In the following, why is the constructor of C not inherited by CExt so that it can be used by another extending contract CExtChild? contract C { uint id; constructor(uint _id) { id = ...
Emanegux's user avatar
  • 123
1 vote
0 answers
24 views

Why is adding a constructor to call an external contract causing a cascading effect on the children requiring them to be marked abstract?

I'm having issues with compiling this contract, this contract sits in a series of inherited contracts. Its #6 of 8 contracts that make up the whole NFT contract. Before adding the constructor I was ...
Benjamin Delgado's user avatar
1 vote
2 answers
39 views

Constructor error: Expected '(' but got identifier solidity

// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract PokemonFactory { struct Pokemon { uint id; string name; } struct Type { string name; string description; } ...
Erick Carvajal's user avatar
1 vote
0 answers
38 views

How to pass argument with a specific interface into constructor for a sucessfull etherscan verification?

I have an marketplace contract that needs to be verified. It looks like this: // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC721/IERC721.sol&...
weird-dreams's user avatar
1 vote
2 answers
291 views

Store string as immutable

I want to deploy an nft contract and i want to enter URI in constructor: string immutable i_uri; constructor(string memory name, string memory symbol, string memory uri) ERC721(name,symbol) { ...
Alireza's user avatar
  • 350
0 votes
1 answer
132 views

Passing bytes32 to constructor

I have s constructor that takes a bytes32 parameter and assign its value to the jobID variable contract APIConsumer { bytes32 public jobId; constructor( bytes32 _jobId) { jobId = ...
noro meb's user avatar
  • 368
0 votes
1 answer
110 views

Facing constructor arguments error while running my staging tests on the goerli network

here is my staging test below which I am trying to test on goerli network: const { assert, expect } = require("chai") const { getNamedAccounts, ethers, network } = require("hardhat"...
Anooj Patnaik's user avatar
0 votes
1 answer
221 views

How to encode a call to deploy a proxy inside a smart contract?

In hardhat, I am deploying an upgradeable smart contract using this script: const v1contract = await upgrades.deployProxy( V1contract, [ "...
Falcon Stakepool's user avatar
0 votes
1 answer
75 views

contract recursive dependency

i have two contracts the first one has a function which must be called only by the second contract : contract A { address contractBAddress; uint256 number; modifier onlyB() { ...
noro meb's user avatar
  • 368
1 vote
1 answer
328 views

How to match number of arguments in constructor and deploy()

This is my constructor constructor (uint256 _initialSupply) { ownerOfContract = msg.sender; balanceOf[msg.sender] = _initialSupply; totalSupply = _initialSupply; } But ...
Taha Ali's user avatar
0 votes
1 answer
61 views

Is it possible to call a function at the time of deployment if it is not in constructor?

This code is from UniswapV2Pair.sol constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address ...
Yilmaz's user avatar
  • 1,610
0 votes
2 answers
223 views

Deploy upgradable contracts using Remix

How can I deploy a contract that has the initialize method from Remix? I have just seen here that Remix now supports this feature but I haven't found any example I could follow.
Falcon Stakepool's user avatar
0 votes
2 answers
457 views

How to initialize a smart contract using Remix?

I have a contract that has this constructor: constructor(address _nativeTokenWrapper) TokenStore(_nativeTokenWrapper) initializer {} And this initialize function: /// @dev Initiliazes the ...
Falcon Stakepool's user avatar
0 votes
1 answer
31 views

How constructor can receive a variable quantity of parameters?

I'm coding a contract factory that will generates a lot of contracts and each contract will receive the constructor below: constructor( string memory _name, string memory _symbol, string ...
Pedro Peres's user avatar
1 vote
2 answers
134 views

How to create migration for smart contract with Struct Array in constructor

I have a smart contract that has the following Struct Array in its constructor: struct Details { string tokenType; address tokenAddress; uint256 tokenId; uint256 amount;...
Falcon Stakepool's user avatar
0 votes
2 answers
244 views

TypeError: Contract should be marked as abstract

I'm getting this error: TypeError: Contract "BaseRegistrarImplementation" should be marked as abstract. --> Contracts/BaseRegistrarImplementation.sol:7:1: | 7 | contract ...
gerbil's user avatar
  • 225
0 votes
1 answer
33 views

Implementing multiple Can't Be Evil license in one contract

I'm looking for a way to implement Can'tBeEvil License in my project, so that the users can select a particular license whatever they prefer. Can it be done in one contract? or i have to create ...
dungexn's user avatar
1 vote
2 answers
884 views

Can ReentrancyGuard be used in Proxies?

ReentrancyGuard's _status is set in the constructor & we can't set it anywhere else: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/64e48203cecad94f02de9891ecdeed4d629c6dae/contracts/...
DiamondDust's user avatar
0 votes
1 answer
71 views

Truffle: { Error: Invalid number of parameters for "undefined". Got 0 expected 1! at module.exports

I am trying to execute the following smart contract using Truffle: pragma solidity 0.5.16; contract Phishable { address public owner; constructor (address _owner) public{ owner = ...
zak100's user avatar
  • 1,406
0 votes
1 answer
26 views

Why do we need constructor in this code?

I heard that constructor is usually used for initializing variables but It just has 'console.log' here. Is constructor essential for every contract? // SPDX-License-Identifier: UNLICENSED pragma ...
Shift_that's user avatar
0 votes
1 answer
26 views

Connect Recipient Wallet - 'receive' function not defined

sorry to bother, trying to get an acknowledgment that my sender(msg.sender) address is sending to the receive() external payable. compiles fine, doesn't deploy correctly to show +1ETH in recipient ...
alastair wright's user avatar
0 votes
0 answers
374 views

passing multiple parameters to deploy script (ethers, upgrades)

I'm looking for the tutorial or instruction manual for parameter syntax My solidity file has the following initializer: function initialize( address addy, string memory _var1, string ...
CQM's user avatar
  • 167
1 vote
1 answer
102 views

Restrict who can call a constructor

I create an instance of a child contract using a Factory contract. I want to limit the constructor of the child to only be called by the Factory. Is this possible? contract Factory { function ...
Reno's user avatar
  • 141
1 vote
1 answer
155 views

Why is VRFConsumerBaseV2(vrfCoordinator) in the constructor declaration?

I am new to Solidity and going through Patrick Collins' online course. In the following code, I was wondering why VRFConsumerBaseV2(vrfCoordinator) is included in the constructor declaration. I ...
J. Doe's user avatar
  • 105
2 votes
1 answer
122 views

Vyper: Call function in __init__, Function does not exist or has not been declared yet

I have some vyper code as such: # SPDX-License-Identifier: MIT # @version ^0.3.3 supply: uint256 decimals: uint256 @internal def updateSupply(_supply: uint256): self.supply = _supply @external ...
Patrick Collins's user avatar
0 votes
2 answers
502 views

How do you pass in a variable as a string to a constructor in solidity

I'm currently working on an NFT project, using the openzeppelin ERC721 standard for the nfts. When Inheriting the ERC721 NFT contract standard from openzeppelin you're required to pass in the "...
Tame.nation's user avatar
0 votes
1 answer
185 views

Solidity dynamic unicode variable

I previously asked about unicode in Solidity and got some great answers (thanks for that!). Issue is now I'm experimenting with passing in the value of a utf-8 (not a literal): constructor (string ...
aug2uag's user avatar
  • 85
0 votes
0 answers
24 views

How to set variable of contract from another contract constructor? Solidity [duplicate]

I have a contract // SPDX-License-Identifier: MIT pragma solidity ^ 0.8.15; contract MomContract { bool public failed =false; constructor(){ new Son(address(this)); } ...
Andy D's user avatar
  • 23
0 votes
2 answers
177 views

How to use truffle-assertions to check if a constructor will revert?

Say I have a contract: contract Reverts{ constructor(param1){ require(param1); } } If param1 is false, the constructor should fail and revert state. truffle-assertions allows me to ...
Expectator's user avatar
1 vote
2 answers
173 views

Smart contract is not available on the blockchain during the constructor call

I have the following sample code: // SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/ERC20....
toongeorges's user avatar
2 votes
1 answer
796 views

Any way to call the constructor of an inherited contract the initialize function using a proxy?

I am deploying a proxy on an ERC721 and Ownable contract. The problem is that the constructor of Ownable is not called on the initialize function so the owner is not defined and the onlyOwner modifier ...
Alejandro de la Cruz López's user avatar
0 votes
3 answers
817 views

can we call constructor in another function of the same contract in solidity?

can we call constructor in another function of the same contract in solidity ? Curious, Kindly reply asap. Thanks
Syed Murtaza Ali Shah's user avatar
0 votes
1 answer
2k views

Passing an array of constructor arguments through hardhat-etherscan in CLI

Here is the code that I used to deploy this contract to the Rinkeby network. const hre = require("hardhat"); async function main() { // Hardhat always runs the compile task when running ...
Gray Blanchard's user avatar
0 votes
1 answer
73 views

Weird problem with address(this).balance and gas

I have a very simple contract, something like this: contract Test_Variable{ uint256 public variable; constructor() { variable = 100; } function balanceTest() public { ...
NomiY's user avatar
  • 3