Questions tagged [contract-development]

Questions regarding the development of smart contracts

Filter by
Sorted by
Tagged with
0
votes
1answer
18 views

Why the gas estimation of erc20 approve() change with executation?

The approve function code in my ERC20 contract is below: function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(...
0
votes
0answers
13 views

zeppelin tutorial smart contract (noob alert) can't connect to network

I am following this tutorial - https://docs.openzeppelin.com/learn/deploying-and-interacting#local-blockchain Everything was going good until i was asked to type the command - $npx oz accounts - ...
1
vote
1answer
19 views

Signing message with private key and verifying signer in smart contract

I have a smart contract that provides a message to sign and then validates the signer of the message. Something like: mapping(address => uint) public userNonce; function getSigner(bytes32 ...
0
votes
0answers
18 views

Token transfer gas is different in rinkeby and private chain

After set up a private clique chain and issued a ERC20 token contract. I compared token transfer gas between estimated amount by web3.eth.estimateGas() and used gas from transaction log. They are ...
-1
votes
0answers
23 views

Can we take input of an address and pass it on the function to send ether using web3 and truffle? [closed]

Actually i am trying to create a betting application so when i get the result that Home team has won Before this i will be taking both address as input (betting do two address whoever wins gets the ...
0
votes
1answer
36 views

Is it possible to get contract payload/data of a smart contract created via instance?

I am trying to get contract instance payload created via instance but don't seem to know how. I don't want to save just the contract address. Kindly help. See my code below. contract LandRegistry { //...
1
vote
1answer
31 views

Clone factory and constructor arguments

In my project I'm using a Clone Factory: https://github.com/optionality/clone-factory/tree/master/contracts function createClone(address target) external returns (address result) { bytes20 ...
0
votes
2answers
22 views

Returning a value from an external function

I have in a contract: function createCourt() external returns (uint256) { uint256 _id = ++nonce; courtOwners[_id] = msg.sender; return _id; } Now, when I try to call ...
0
votes
2answers
28 views

Save data in transaction generated through a smart contract [closed]

I want to lunch a clustering (procedure) algorithm in off_chain on data recorded in an IPFS. Input: my data, k: number of cluster or class Output: data clustered or labelled in class k How to save ...
0
votes
2answers
32 views

How to see data sent using a smart contract?

See this transaction: https://rinkeby.etherscan.io/tx/0xf38b9f1fdb1a6f309bb4671bbcee235c9b75685ac96f99955d59b9a112db1156 Is referred to the creation of this contract: https://rinkeby.etherscan.io/...
1
vote
1answer
29 views

Cannot transfer ownership of ERC20 contract

My contract source code likes below: contract StandardToken { uint256 totalSupply; ... } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } ...
0
votes
1answer
12 views

A smart contract's storage problem , further ERC ?

Er .. I have a question about smart contract , a single smart contract's storage capacity Follow the answer is this question: Is there a (theoretical) limit for amount of data that a contract can ...
0
votes
1answer
19 views

Simple contract question, am I the owner?

I started a contract through etherscan's publish and verify. But the contract hash it isn't under my verified address? Is this normal?
0
votes
1answer
44 views

machine learning (clustering algorithm) in smart contract [closed]

i want to implement a clustering algorithm (k-means for example) in a smart contract. for the traning data (big Data Set) , i want to use IPFS(off-chain) to save my dataset. is this Idea Correct? ...
0
votes
2answers
33 views

IP address and system details of msg.sender

Is it possible to log the IP address and various system details (meta data etc.) about a msg.sender who is sending a transaction to your smart contract?
0
votes
1answer
22 views

When I hit sign transaction in deploying contract, the send button is greyed out

I have 0.5 ROP but it is saying send 0. My wallet address is 0xef534b8ea9B3897a014Bf47E84c642Ad7952A120
0
votes
1answer
17 views

Storing Tokens In The Most Secure Way

What is the most secure way to store tokens, if you are to roll out an ICO or similar? I know there are many ways, i.e. sharding the private key but what is the best practice right now? If I assign ...
0
votes
1answer
32 views

VM error: revert.The called function should be payable if you send value and the value you send should be less than your current balance

There is already a similar question, but it doesn't help me. So I ask this question again and expect something useful information. Two contracts named AccessControl.sol and Judge.sol. I've removed ...
1
vote
1answer
17 views

Besides Etherscan, Are There Other Places to Verify/Publish Contract Code?

The title says it, but I also need at least 30 characters.
1
vote
2answers
90 views

Can a contract be deployed through a node which is not owned by the contract owner?

I want to create a private network, and allow anyone to deploy a contract via an RPC call. Is it possible to allow someone to deploy a contract via a node that they do not own?
0
votes
0answers
45 views

Smart contract works on remix and ganache but not on private chain developed by geth

The smart contract works well on the ganache and remix but not work on the private chain, even though i use the --testnet geth --identity "EDU" --rpccorsdomain "*" --rpc --rpcport "8545" --...
1
vote
0answers
9 views

Geth's golang contract bindings need “RPC subscription features that are still under review” to process event logs. What are those features?

The documentation for Geth's golang contract bindings start out with Please note, events are not yet implemented as they need some RPC subscription features that are still under review. What ...
0
votes
1answer
13 views

How to invoke functions or get data in/of a contract from another contract?

I have a contract that creates instances of a contract and now I have to get the data of the newly created contract. Is there a way to do that? This is my contract that creates new contracts: pragma ...
1
vote
1answer
24 views

Is it considered secure at all to use passwords and private keys in the code of smart contract?

Basically something like: function transfer(address to, string privkey) { if(privkey == "cd33434343...") { msg.sender.transfer(this.balance); } } The above is obviously flawed since the privkey is ...
0
votes
1answer
21 views

Is function like this one reentrant?

Got this in pseudo-code (Solidity like...) from audit of past work of person from our company, in short it seems to be withdrawing first and adding later. Maybe not a good idea, especially since it's ...
6
votes
0answers
42 views

How to Measure and Manage Witness Size

In https://ethresear.ch/t/the-eth1-eth2-transition, Vitalik wrote: If you are a developer, you can eliminate the largest part of disruption from gas cost changes by proactively making sure you ...
1
vote
0answers
27 views

Is there a way to deploy a contract using bytecode only (to Ropsten …)?

One solution on medium.com describes how to do that via myetherwallet but it's the old verion of myetherwallet where you can switch between ropsten/mainnet - right now I can't find how to switch to ...
1
vote
0answers
16 views

How dangerous is this: number of contracts contain a function like “approveandcall” which lets anyone call any contract (some thoughts?)

The most common implementation is as follows: function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(...
2
votes
2answers
38 views

Revert()/throw/invalid are so powerful they can even put back an already self-destructed contract, but is there a way to surpass such limitation?

I know this sounds confusing so let me explain: In this case below a transaction will succeed and a contract will be first destroyed and then re-initialized on the same address (yes, I didn't think ...
3
votes
2answers
30 views

Variable Names and Memory

Is there a cut-off where a variable name uses more memory? For instance: uint public priceOfEthYesterday9AMUSAET vs uint public pEth One is more descriptive, but if it's costing me gas I don't ...
1
vote
1answer
31 views

How are transfer and send protecting against reentrancy if the gas is taken from the EOA (msg.sender)?

I guess transfer and send simply allow 2300 gas but no gas is taken from the contract? In other words if a wallet calls this function with say one million wei gas: function sending() public payable { ...
2
votes
1answer
26 views

How dangerous is to use tx.origin to check if msg.sender is some address? (details below…)

Let's say: function transfer() public payable { require(tx.origin == 0xb2930B35844a230f00E51431aCAe96Fe543a0347); msg.sender.call.value(1 ether)(); } Ignore the address above I just copied it ...
0
votes
0answers
27 views

Retrieving the first and latest transaction date of a contract

Etherscan offers a time series of ethereum transaction of a contract address. Is there a way to retrieve this data? For example the duration mentioned here https://etherscan.io/address/...
0
votes
0answers
14 views

Is function like that prone to reentrancy?

function transfer() payable public returns(bool) { balances[msg.sender] = SafeMath.sub(balances[msg.sender], msg.value); if(msg.sender.call.gas(100000).value(msg.value)()) { ...
1
vote
1answer
51 views

Vyper fundraising smart contract: 'Attribute' object has no attribute 'func'

[SOLVED]: See below. I am taking a blockchain and security class and we are working with vyper. We have been tasked with rewriting a fundraising smart contract. However, the compilers do not seem to ...
0
votes
0answers
25 views

How to connect to Mist without access to internet?

I need to connect to Mist without access to internet. How I can do it without download any other software?(except geth, of course) With a default connection, I get errors: [ERROR] Sockets / node-ipc -...
0
votes
1answer
21 views

Writing string to separate block in Ethereum

Is it possible to take input of a string from client side and using smart contract write that string data to a new block inside the Ethereum blockchain mainet or any testnet? Basically take in ...
2
votes
2answers
39 views

Programming Practice - using requires with return types

Can I please get some help with the following? Is it acceptable practice to allow my functions to rely on require statements "passing" to return the correct value? In the example below if the ...
3
votes
1answer
19 views

Can I add an int32 to an int256?

I'm trying to reduce the storage size of my contracts by reducing the bytes required to store my int data types (among other things). Can I get the best practice for adding int256 and other smaller ...
0
votes
1answer
25 views

Is there a case in which selfdestruct is more “powerful” than throw or revert?

Example in this scenario I guess selfdestruct will never get called (also: contract A isn't so important by the way just focus on B onward): in Contract A: address contractb = 0x....; function ...
1
vote
0answers
10 views

Is there a standard for modelling smart contracts such as ERM for databases?

I want to document my Dapp including the "data structure" (i.e. the relationship between different contracts). Is there a good way of modelling smart contracts that anyone has used successfully?
1
vote
0answers
52 views

Error: Cross origin null forbidden : ---Problem in downloading Open source contracts from Etherscan.io

UPDATED: I am trying to download source code of open source verified contract from Etherscan.io. Here is my procedure as directed by Ann. 1. Download CSV file of captioned contracts. 2. Write ...
0
votes
0answers
14 views

Is it possible to create false positives, aka “throwing exception” on purpose in solidity?

I've been playing with this over the past weekend and it seems impossible, I guess since it's considered a big security issue if it was possible. Example to illustrate what I am trying to achieve: ...
0
votes
2answers
26 views

It seems impossible to perform some action and then throw returning an error?

How can I accomplish something like this: accept ether, set owner or anything and then return 1, throw...just return This doesn't seem to work despite crossing through functions and using if ...
2
votes
1answer
45 views

In “msg.sender.call.value(msg.value)”, where is msg.value taken from?

Given the following example: function x(address receiver) public { receiver.call.value(msg.value)(); } Am I correct that receiver can be any address but msg.value cannot be controlled via ...
0
votes
1answer
40 views

Smart Contract deployment failed

I am making my project of BlockChain subject. I am having a problem with deploying smart contracts. Can anyone help me with this error I have tried everything I could but still failed to resolve this ...
0
votes
0answers
21 views

Did I get this right that with delegatecall the msg.sender is the last entity that calls delegatecall (example below)?

In other words: If contract B is called by contract A: B: function externalcall() public { //msg.sender is contract A... msg.sender.call.value(0); } Then assuming msg.sender.call above calls back ...
0
votes
0answers
13 views

Cannot use delegatecalls in Remix since either the addresses aren't displayed correcly or I cannot access the memory address?

For instance delegatecall to the same address works: function callTheOtherContract() public { require(address(this).delegatecall(bytes4(keccak256("callMe()")))); } event CallMe(...
0
votes
0answers
22 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
11 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 ...