Questions tagged [constructor]

The tag has no usage guidance.

26 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
673 views

Passing constructor arguments from child contract to parent contract

The ERC721 standard contract requires a token name and symbol in its constructor. I have inheritance pattern that looks likes Contract A is B and Contract B is ERC721. If I want to set my token name ...
2
votes
0answers
242 views

Error! Invalid constructor arguments provided. Please verify that they are in ABI-encoded format, I tried (https://abi.hashex.org/) but still no luck

Good afternoon! I want to create a NFT and my code is working fine in remix. An error occurred while adding source code to ropsten: Error! Invalid constructor arguments provided. Please verify that ...
2
votes
0answers
447 views

Passing struct into new contract through constructor

I have a function in my ChangeManager contract which should create multiple ChangeRequests. I tried to model a Change by using a struct and pass this from my ChangeManager to the ChangeRequest: Code ...
2
votes
0answers
32 views

Why not possible limiting gas but forwarding ether in creating this contract from Solidity documentation

In the Solidity docs Creating contracts via new there is an example: contract D { uint x; function D(uint a) public payable { x = a; } } and it states in the accompanying text: ...
1
vote
0answers
62 views

Creating Initial ERC721 Tokens Programmatically

I'm interested in minting 100 unique tokens in the constructor of a smart contract, but I'm having an issue where the minting function hasn't been defined yet while the constructor runs. Do I have to ...
1
vote
1answer
457 views

Using inherited constructor in Solidity >=0.5.0

I want to use a contract inherit from another contract and use the parent constructor after using another commands in inherited constructor. So I wrote: pragma solidity ^0.5.10; contract A { ...
1
vote
0answers
23 views

How to enable constructors in the new REMIX IDE or Truffle framework since MIST is depreciated

I used to dabble with making tokens and contracts and started to get back into it. I liked the functionality that mist offered where you could input constructors values directly in mist. I can not ...
1
vote
0answers
324 views

How to listen for contract creation, or all block events?

I'm building a web app with web3 where users can deploy a certain contract and assign some people to it. Inside the constructor of that contract I also output a certain event. I want these assigned ...
1
vote
1answer
136 views

How to share TypeScript code between truffle tests?

I have some code in my TypeScript tests, say: function foo() { return 'bar'; } which I'd like to share with all my tests. The simple solution is to copy the function into each *_test.ts file. ...
1
vote
0answers
124 views

the constructor should be payable if you send

I have been testing the code and for some reason I am having a block. The error is described as "the constructor should be payable if you send value". The debugger points to " uint256 weiAmount = ...
0
votes
0answers
11 views

TypeError : Member "userAddress" not found or not visible after argument-dependent lookup

Im trying to use constructor to assign user address to msg.sender constructor() { userAccount.userAddress = msg.sender; } userAddress being a property in my struct datatype , but i keep getting this ...
0
votes
1answer
15 views

I deployed a contract on remix, but none of the constructor variables are viewable

I inherited the ERC-20 standard contract, but when I compile and deploy, none of the constructor variables are viewable. This problem persists even when I change "private" to "public&...
0
votes
1answer
31 views

Correct Constructor arguments for basic timelock contract

just wondering why I can't get this constructor to pass. What am i doing wrong ? // SPDX-License-Identifier: MIT // TeamLockTest pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/...
0
votes
1answer
12 views

I'm trying to deploy a Wallet onto the Blockchain AND deposit some Ether in it AT THE SAME time...... ie using the Remix DEPLOY button

I feel this should be VERY SIMPLE. So code the Constructor to require an Amount and therefore that Amount will be then taken from the Metamask Wallet at the same time as the GasFees are paid for the ...
0
votes
0answers
18 views

How to turn constructor arguments into ABI-ENCODED values?

The constructor of my smart contract has arguments. How can I turn constructor arguments into ABI-ENCODED values? I have to use it on bscscan.com.
0
votes
0answers
6 views

parsing error in smartcontract constructor

parsing error in smartcontract constructor, can some one please help me out and show me what I am doing wring and why this error is even thought everytrhing is looking fine from outside.
0
votes
0answers
30 views

Buying ERC1155 token with payable

The constructor for ERC1155 token standard looks like this: constructor() public ERC1155("https://game.example/api/item/{id}.json") {} However, the example given on OpenZeppellin mints all ...
0
votes
0answers
32 views

How to view what arguments were passed to the constructor function of a deployed contract retroactively

Take this Animetas NFT contract for example: https://etherscan.io/address/0x18df6c571f6fe9283b87f910e41dc5c8b77b7da5#code I want to see what values were passed into the constructor function when this ...
0
votes
1answer
369 views

Ethers js deploy contract with balance, payable constructor

I have a smart contract with a payable constructor. I'm trying to figure out the syntax with ethers js how I can deploy the smart contract and send an initial balance with the deployment. const ...
0
votes
1answer
19 views

Does it matter if state variables are assigned value in line or in the constructor?

For example, is there a difference between these two snippets of code, or is there a best practice? From my experimentation, it doesn't seem like it makes a difference. Thanks. contract A { uint ...
0
votes
1answer
33 views

The called function should be payable if you send value and the value you send should be less than your balance

This is one of my parent contract (child factory contract) functions that creates a child contract. The function should be provided with 3 arguments function breed(uint _number, uint _amount, ...
0
votes
1answer
38 views

Converting constructor from 0.4.25 to latest version

The syntax of constructor in version 0.4.25 was contract A { address newContract; function createContract(uint a, string memory b, address c) public { newContract = new B(a, b, c); } } ...
0
votes
1answer
499 views

Cannot figure out how to set constructors and ABI for a contract

So I've been breaking my head over this for the last 2 days. I cannot seem to figure out how to get the constructors and ABI set up properly. I'm testing smart contracts by copying Sushi contract from ...
0
votes
1answer
33 views

How much Ether does a Smart Contract Address hold before a Payable Instantiation?

The following code always reverts to "Contract must be empty". But shouldn't address(this).balance == 0 if the contract hasn't even been instantiated yet? Maybe since the contract doesn't ...
0
votes
1answer
947 views

address.transfer(value) is throwing error in solidity contract.

I am building an approval contract in Remix and have been stuck on this issue. When I try to transfer wei using address.transfer(value), it throws an error. I have marked it in the code below. ...
0
votes
1answer
51 views

Push large number of items in mapping with constructor or other methods

I would like to push large number of items into mapping. Prototype looks like this mapping (uint => string) ipfs_hashes; constructor() ERC721("GameItem", "ITM") public { ...