Questions tagged [solidity]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

Filter by
Sorted by
Tagged with
0
votes
1answer
9 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
15 views

Invalid implicit conversion from int_const 0 to address requested [duplicate]

Invalid type for argument in a function call. Invalid implicit conversion from int_const 0 to address requested.
0
votes
1answer
18 views

How to check when erc20 token was received in certain address

i am hosting a node and fully sync it. how i can call its api endpoints to figure out when DGX is received in certain wallet addresses.
-1
votes
0answers
7 views

autocall send recieve tokens (what is best way )

my need : autocall for m-reson happen in my contract to send ETH to m_address of binance sell it there and then send back usdt to contract is there a way to do this in decentrlized way ? ...
0
votes
0answers
3 views

input field is not getting displayed by using ContractForm

<DrizzleProvider options={drizzleOptions}> <LoadingContainer> <div> <h1>Welcome Doctor</h1> ...
0
votes
0answers
23 views

How can execute function that send ether in geth console?

I want to execute the send function that sends ether from the sender to the receiver, the code is as shown below. contract Sender { function send(address _receiver , uint amount) public ...
1
vote
1answer
12 views

how to create Function Selector (Method IDs)

As stated in ABI specs that 0xcdcd77c0: the Method ID. This is derived as the first 4 bytes of the Keccak hash of the ASCII form of the signature baz(uint32,bool). So, I have to create method IDs (...
0
votes
1answer
17 views

Dispute in smart contartcs

i don't have enough knowladge of contracts. any one have a good article about What is arbitration and dispute in smart contracts.can you please help.
0
votes
0answers
16 views

TypeError: CreateListFromArrayLike called on non-object

I have this contract and deployed it to my local client (ganache gui) and its abi.json file (of solc compiler generated). The third file is param.txt which contains encoded functions with arguments ...
-1
votes
1answer
32 views

Using await with web3 function calls

I have just implemented a tweak to make my asynchronous call run sequentially, however it is messy solution. I have got the following code: async function myClick() { calculateAmounts(); ...
0
votes
1answer
20 views

I´m new to Ethereum and Solidity, ¿can anyone help me?. Thank you!

I have to: Write a Contract Constructor that will store the addresses at each of the member variables you declared in the previous stage. The arbiter and beneficiary will be arguments to the ...
0
votes
1answer
18 views

How to store data on ethereum blockchain WITHOUT IPFS

Hi guys ^^ i want to store PDF file on ethereum blockchain without use of IPFS. I want to do it because i have my own private network where this data will be only stored. That's why i want to store it ...
0
votes
0answers
11 views

Compiling Old Version Contracts , gives ParserError: Expected pragma, import directive or contract/interface/library definition

Ihave to compile some old contracts (having solidity pragma is <0.5. For this purpose, I have just copy and paste this contract from Etehrscan and save with its name in contracts folder. Install ...
0
votes
0answers
12 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)()) { ...
0
votes
1answer
14 views

How to handle an ERC20 token which does not return true/false at the end of transfer/transferFrom

The ERC20 Token Standard dictates that functions transfer and transferFrom should return true for success and false for failure. However, various ERC20 tokens deployed on the network have not ...
2
votes
1answer
43 views

Is transfer() still safe after the Istanbul update?

In other words, is using transfer() safe? function transfer(address contractB) public { contractB.transfer(1000); //balances[msg.sender] -= 1000; } How about using call.gas? function ...
0
votes
1answer
17 views

Function Efficiency

Say I have a function that handles 4 cases via if statements. I could break that into 4 separate functions. The case for breaking it up is that each function call would use less gas. The case against ...
0
votes
0answers
14 views

Solc Compiler related Error in Nodejs

I have almost 800 .solc files of version ^0.5.12 (i am using also 0.5.13 compiler version), when i all give them to my input, to compile with following code; var walk = function (dir) { var ...
0
votes
0answers
18 views

How to import mySQL data to Solidity?

I have created a mySQL database through phpMyAdmin, storing health data. I would like to use Solidity to develop a smart contract which will implement access control to the data in the database. My ...
0
votes
0answers
9 views

nested calls fail on geth --dev but pass ganache-cli

I have the following solidity contracts defined. I want to test nested calls using the lowlevel api where C->D->E. However, running this code passes on ganache-cli but fails on geth --dev node. Im ...
0
votes
0answers
19 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
15 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 ...
1
vote
2answers
36 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 ...
0
votes
1answer
17 views

Transaction Timing Implications for Reentry Attacks

This is the classic reentry attack: function withdrawBalance() public { uint amountToWithdraw = userBalances[msg.sender]; (bool success, ) = msg.sender.call.value(amountToWithdraw)(""); ...
0
votes
0answers
7 views

Web3py how to save accounts (private keys) to databases

I am wondering if there is a best practice when using web3py to generate an account, i.e private key, and save to to a database. Which format should I use to save it to a database? does web3py have ...
1
vote
1answer
20 views

A Way Around Restricted Getters

Consider a getter function with a restriction on who can read it, like function getData() public view returns (uint x) { require(msg.sender = '0x123..123'); x = data; } This ...
2
votes
0answers
23 views

In solc 0.4.x assembly, how can I check if a non-constant function returns 'bool' or nothing?

I know how to do it for a constant function, for example: pragma solidity 0.4.25; contract Callee0 {function func() external pure returns (bool) {return false;}} contract Callee1 {function func() ...
1
vote
1answer
23 views

raw transactions to send ERC20 token fails on private network(POA)

I am trying to transfer ERC20 tokens on private ethereum network(POA) Transaction flow: raw tx object creation on backend. { "gasLimit": 37000, "gasPrice": 4000000000, "...
0
votes
1answer
21 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 ...
0
votes
1answer
28 views

I am using already deployed tokens in my contract

My question is if I'm not implementing ERC-20 methods in my contract, but I'm using already deployed ERC-20 contract methods in my contract, so can we say this will be ERC-20 compliant contract? ...
1
vote
0answers
19 views

Is there a way to view the private key of test account in Remix (javascript VM)

Seeing how the keys are random and those "100 ethers" aren't real I can't think of why this is not obvious functionality, I'll need this for many reasons.
0
votes
1answer
11 views

browser/demo01.sol:8:33: ParserError: Expected '{' but got 'return' function age() private view return (unit) ^----^

pragma solidity ^0.4.24; //properties functions request contract AttrFnDemo{ uint private _age; string internal _name; int public _num; function age() private view return (unit) {...
0
votes
0answers
14 views

Solidity's address.transfer() function throwing exceeds gas limit error

I am learning Solidity in order to make a simple user interface in which users can purchase items and have ether sent from the purchaser to the Store. First, I have created one contract, one for the ...
0
votes
0answers
10 views

msg.sender is different from chosen account in Metamask when checking from constructor

I am trying to do a comparison of msg.sender and another address inside a contract constructor. The problem is that in the constructor, msg.sender is a different address from the one I chose in ...
0
votes
2answers
25 views

Position of emit

I'm new to solidity and wondering where the emit should stay inside a function. For example: function getPlayers(address players, bool enabled) external { require( msg.sender == _admin, ...
0
votes
1answer
20 views

Truffle js test. Test not really testing

I have this tests that supposedly pass (in the terminal, I can see the checks). But they never actually run the code: it("should add an exam to the exams list", () => { let hash_test = "...
0
votes
1answer
9 views

web3py error while interacting with smart contract 'message': 'execution error: revert', 'code': -32000

When I try to interact with the contract with web3.py, I am using ganache, I get the completely useless error message: ValueError: {'message': 'execution error: revert', 'code': -32000, ... , '...
-1
votes
0answers
9 views

Warning! Error encountered during contract execution [Reverted] in Vesting Contract [closed]

I created a vesting contract it is same with maticvestingcontract https://etherscan.io/address/0xcbfe11b78c2e6cb25c6eda2c6ff46cd4755c8fca#code when what should ı do for withdraw from vesting contract. ...
0
votes
0answers
15 views

Help me fix Error: No “from” address specified in neither the given options, nor the default options. I'm use MetaMask

file web3.js import Web3 from 'web3'; const web3 = new Web3(window.web3.currentProvider); export default web3; file image.js import web3 from './web3'; const address = '...
0
votes
0answers
6 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?
0
votes
0answers
13 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
0answers
25 views

Why does this code outputs error:“unknown account”?

Python code: from web3 import Web3 import json web = "http://10.0.141.114:8545" web3 = Web3(Web3.HTTPProvider(web)) abi=json.loads('[ { "constant": false, "inputs": [ { "name": "_cad_number", "type":...
-3
votes
0answers
14 views

how to solve the syntax error and debug it [closed]

Expected identifier but got 'function' function test() public{ ^------^
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
29 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
13 views

Truffle Error: ContractName has no network configuration for its current network id (1575203139857)

Im doing the tutorial at https://github.com/ConsenSys-Academy/proof-of-existence-exercise and running into the following error: $ truffle console truffle(development)> var poe = await ...
0
votes
1answer
27 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
18 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
1answer
23 views

How does smart contracts exactly work?

I have read about smart contracts and I am left with some doubts. Every invocation of a function in smart contract is a transaction which costs some ether.A miner chooses a smart contract on ...
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(...