Questions tagged [contract-development]

Questions regarding the development of smart contracts

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

Is there a way for a function to perform some code to a point and then revert without conditions (more details below…)?

I want to create a payable function that acts similarly to onlyowner modifier, or: function owner() public payable{ if(msg.sender != owner) { balances[owner] += msg.value; revert(); } } What ...
1
vote
0answers
14 views

Any idea how to add new contracts into drizzle react app using the address?

I have a react app which creates new contracts. lets say A creates B. I have the addresses of the newly created contracts of B. How do i add the newly created contracts of B using its address to ...
2
votes
1answer
32 views

Solidity. Find whether a key exists in a mapping. Then get its value

I have a simple mapping: mapping(address => string) professorsExam; How can I check if msg.sender is a key in this mapping, and if it is, get its value? If it isn't I should return something. ...
0
votes
1answer
16 views

Can you change a variable outside of a function (assuming this variable may be a constant)?

In other words if a contract looks like this: contract tokenX { bool public started = true; function end() { started = false; } } So everyone should be able to call end() but can someone call "...
0
votes
1answer
16 views

So can I simply send ether to a contract as if it's a regular wallet, even without payable function?

Are contracts really that different? I guess in theory every contract should have a private key somewhere + it should be possible to send ether to it? Unless geth/parity and other parts of the evm don'...
0
votes
1answer
19 views

Get contract data if all I have is a contract address

I have the address of a smart contract and I need to get the data residing in that address. I seem to have been struck at this for a while now and I want all this inside a smart contract. pragma ...
0
votes
1answer
308 views

Sending money through a smart contract

I'm trying to create a smart contract that would send funds from one wallet to another by taking values ​​from an array that I fill. But it does not send values ​​unless I specify them in msg.value. ...
0
votes
2answers
37 views

Is this function prone to underflow hacking?

So I want to write as simple as possible withdrawal function in a token contract which also doesn't use Safemath for one very simple reason: I admit I don't understand well enough data types in EVM so ...
0
votes
1answer
23 views

Does it make sense to require token value to be anything but negative to prevent hack (more details below…)?

I was asked to validate a smart contract for a token and a function that puzzled me looks like that: function transferFrom(address _from, address _to, uint tokens) { require(...
1
vote
1answer
27 views

Automatically extracting functions names and parameters from ABI JSON file

I have done some work on captioned subject. For example, I can extract all getter functions (and some constructors as well) of all given smart contracts (in abi json file format). Then i can call (...
0
votes
0answers
44 views

How to build a P2P wager contract with Solidity

I am looking to build a contract with Solidity that will take wagers on a football game between a bunch of friends. Each user should be able to place a bet on either team, with each bet to be added to ...
2
votes
2answers
36 views

loop though all the members of a map

I need to loop though all of the members of a map and change their property (which is a struct). the way i'm doing this is when adding a member to the map object also save it's address inside an ...
0
votes
1answer
38 views

Could not call contract function with its signature

Web3.js documentation says here that the methods of a smart contract are available through: The name: myContract.methods.myMethod The name with parameters: myContract.methods['myMethod(uint256)'] The ...
0
votes
3answers
81 views

Emitting Transfer Event even when there is no actual transfer

I am new to smart contracts and trying to understand it so that i can detect Ether transfers done to my user via Smart Contract. I know I can find the event emitted from topics[]. But for those ...
1
vote
1answer
16 views

Many-2-Many ERC721 Pattern?

I'm looking to build a smart contract with a function which is able to generate a unique and limited amount of ERC721 tokens based on an input string. I also want to be able to look up all the tokens ...
0
votes
2answers
94 views

Solidity contract reentry attacked

The idea is to have a user call send() with some eth. The contract decides if user won/lost. Winner gets a prize msg.sender.transfer(msg.value + winnings); loser gets nothing. Unfortunately the ...
0
votes
0answers
45 views

How can I call selfdestruct when it is located in a constructor and not in the ABI of my contract?

I am reading some tutorials and while planning to deploy test contract on ropsten I have something like this: pragma solidity 0.5.1; contract destroy { constructor(address payable receiver) ...
0
votes
1answer
26 views

Could not call contract function

I want to access the balance of contract(i.e. 0x552F3AfaA0394632f4aEfa9E923fA3e2bbDAF5FE) and its totalSupply(state variable). I could access the balancec of this contract , but why I could not call ...
1
vote
1answer
31 views

How to search value in data field transaction

I need to look for a value in the data field of a transaction and to know which transactions contain the desired value. Let me explain with an example. In the data field of a transaction there is for ...
0
votes
1answer
49 views

How to deploy and get address of smart contract in same javascript program

I want to deploy a smart contract (provided in .json file) and need its address (on testnet blockchain) and then try to send some transactions to it. All these should be done through javascript. Here ...
0
votes
2answers
113 views

Linking to Compound Smart Contract

I'm still new with the solidity and it seems to be a very basics question. What i'm trying to do is to call the link the compound smart contract with mine. And when i try to compile is complaining : "...
0
votes
0answers
20 views

Does a contract creation failure leave the target address with nonce 1?

When contracts are created, they start with nonce 1 not nonce 0. This is since the implementation of EIP-161. The ETH wiki page on nonces outlines what happens when a contract A tries to create a ...
0
votes
0answers
21 views

Can a dapp/smart contract execute a transaction based on a private github file modification?

Scenario Suppose someone promises to deliver code to a private repository, that person is so sure they will, that they even said: "here is x eth, if I don't deliver in time, send the x eth to a ...
-1
votes
1answer
72 views

Unable to test a smart contract on ropsten test network

I launch and verify an ERC20 based smart contract on a ropsten test network which allows user to interact with the contract (send eth to it and the contract automatically send token in returns as in ...
0
votes
2answers
58 views

How to get the result by parsing the log after executing the contract? How can I get the execution result?

How to get the result by parsing the log after executing the contract? How can I get the execution result ?
0
votes
1answer
30 views

Desired Revert if Condition Is True [closed]

What is the best way to revert inside a function if a particular condition is true? Sometimes safeguarding with require statements is not enough, i.e. uint256 constant public OFFER_LIMIT = 500 ...
0
votes
1answer
28 views

Memory Utilization Pattern Solidity?

I was wondering what is the most efficient way (and why), to use variables in memory for function calls with regards to A and B? A) Like this: function checkBalance() public view returns (uint256) ...
0
votes
1answer
57 views

smart contract is too smart: different bahaviors of smart contract on different version of geth or solidity

recently I am learning how to deploy and call smart contract on ethereum. I am working on a very simple contract as follows: pragma solidity >=0.4.24 <0.6.0; contract TestContract{ uint ...
0
votes
0answers
11 views

Retrieving ERC-223 token address on tokenFallback() function

I made a sample smart contract that can update the value of different existing ERC-223 tokens received in the contract as below. Assuming that the IERC223 was taken from here. address[] ...
2
votes
1answer
95 views

How can a smart contract store mutable data outside blockchain?

As storing persistent data on blockchain is costly due to the storage operation being gas-expensive, what are the solutions to store mutable data outside the realm of blockchain from within a smart ...
0
votes
1answer
68 views

What does it mean to flush to an ethereum address

If ether is sent to a contract then flushed to an address what does this mean? Does it mean the contract sends the money to a recipient?
0
votes
1answer
46 views

Payable external function call not updating state variables

I'm trying to get buyToken() to update the balance of the caller. I'm using Truffle and Ganache, running tests, but the testBuyToken() function keeps failing, apparently the BALANCES variable isn't ...
0
votes
0answers
21 views

How do a set cookie for a Dapp's front end and pass the information to blockchain?

I am trying to look up documentation on setting up cookies for my dapp using web3 but I am unable to find resources. Can I just use js functions like setCookie and getCookie as one would do for a ...
0
votes
1answer
27 views

Need to enumerate keys of a mapping [duplicate]

I have a directed multigraph of courts "trusting" each other: struct TrustedCourt { uint256 courtId; mapping (uint256 => uint256) limits; // intercourt token => amount } ...
2
votes
2answers
113 views

How to generate a new token for ERC1155?

Developing an ERC1155 contract, how to generate an address for a new token? I need to create an API function like function createToken() returns (address). How? Should I just use an incrementing-by-...
1
vote
1answer
44 views

Error Handling on Contract Calls to Other Contracts

I'm trying to call a function from another contract and need a way to accommodate errors. Say contract A has the method getBalance: function getBalance(address x) public view ...
0
votes
0answers
36 views

Comparison of 2 child-contract-values in factory-contract

in my solidity code I create a tracking-contract and auction-contracts out of a factory-contract. The last function 'a4_Payment' of the auction-contract should be triggered out of the master-contract ...
0
votes
0answers
22 views

Can a factory-contract access/read/modify variables in generated child-contracts?

at the moment I am experimenting with the factory/child-logic in solidity. With my factory contract I am able to create child contracts in which an auction is executed. Now I want to return a variable ...
0
votes
2answers
62 views

Could I implement a kill switch in my solidity program?

I was wondering if there was a way to put a killswitch into my solidity code? I am using v0.4.21+commit.dfe3193c Thanks a bunch!
0
votes
1answer
210 views

How estimate GAS from a contract call with Web3j

I'm trying to estimate gas cost of a contract call, i need to send a string to a contract, but i need to see if i overtook the GAS limit. I'm trying like this: Transaction t = Transaction....
0
votes
1answer
40 views

Is there any chance to retrieve data on a database(sql) to a smart contract [duplicate]

I want to write a smart contract that gets id numbers as inputs and then retrieve data that are recorded in a database.Is there any specific database for that process.
0
votes
1answer
74 views

Solidity - Creating child contract

Recent code: pragma solidity ^0.5.11; pragma experimental ABIEncoderV2; contract Master { address Pi_C_Owner; address payable public NewAuctionPayable; //Hilfsvariable um ...
0
votes
0answers
139 views

Failed to compile <modul not found>

please help me Module not found: Can't resolve 'web3' in 'C:\Users\block\src\components' i don'k know why .. my app.js import React, { Component } from 'react'; import logo from './logo.svg'; ...
0
votes
2answers
88 views

Check if contract exists in list

I've got a contract which creates another contracts and stores them in a list. How can I check that contract with specific index already exists? import "./User.sol"; contract Main is Ownable { ...
0
votes
1answer
39 views

Must consider things for every smart contract

When creating smart contract from scratch, what kind of things you should consider? For example: 1.Certain functions should be accessible only by creator/specific addresses 2.Fallback function Is ...
0
votes
1answer
42 views

Keeping a finite set of addresses (Solidity)

struct Data { ... } contract Court { mapping(address => Data) subcourts; } I want to keep track of a small finite set (which can be added or removed) of all keys of this mapping. What is the ...
0
votes
0answers
18 views

Auction Contract with “Right to Bid”

I build a basic reverse auction you see here using Solidity and the ethereum remix IDE. In addition to the functionalities already implemented I would like to add a "SafetyLimit" amounting to half the ...
0
votes
1answer
85 views

Linked contracts not running on go-ethereum

A very simple linked contracts example where A contract has a variable and B contract queries the A contract's variable is running ok on Ropsten+myetherwallet and Remix sandbox, but it fails when ...
0
votes
0answers
34 views

Bunch of Smart contracts with Ownerships and User fees free transfers

I need a community advise on how to organize smart contracts architecture. So what we have: Users who have not eth and wallets. Users generate actions which involves token transfers. Users don't care ...
0
votes
0answers
24 views

which type can use to store abi in a contract

If I want to store abi in contract, which type can be use? and How can I get it later. For example, if I use bytes to store a contract's abi. How can I use JSON.parse to get it. I have not find a ...

1
3 4
5
6 7
64