Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
4 votes
Accepted

What is the default visibility of a variable in solidity?

If visibility is not specified then by default it is an 'internal' variable . So , the owner mapping above is internal .
Gaurav Pant's user avatar
3 votes
Accepted

Who is msg.sender in a nested delegatecall chain?

It's the original msg.sender (the one who calls callMe on contract D) because msg.sender context are all the same in D,C,B,A. For example, user having an account 0x1111... calls callMe(a,b,c) on D, ...
minhhn2910's user avatar
  • 1,760
2 votes

check if a DELEGATECALL has taken place during the transaction

I think you are right, considering that you cannot control or write the logic in A and B, it seems impossible. However, if we consider only your example of 3 contracts, there could be an expensive way ...
minhhn2910's user avatar
  • 1,760
2 votes
Accepted

Can the smart contract automatically send the amount received to the owner's address or any fixed address defined in the contract?

When you send ETH to a smart contract, you're actually calling its receive() function (https://docs.soliditylang.org/en/v0.8.17/contracts.html#receive-ether-function). If that function contains logic, ...
Foxxxey's user avatar
  • 4,317
2 votes

What is the default visibility of a variable in solidity?

it's internal, meaning that only functions from derived and internal contract can use it.
Raphael's user avatar
  • 41
2 votes

How to deploy a contract and a library together using HardHat

You have to deploy the Solidity Library that has either a public or an external function to use it from a smart contract. This library would then sit on a separate address and your smart contract make ...
rolandsaven's user avatar
2 votes

How to deploy a contract and a library together using HardHat

I found a solution; you have to first deploy the library and then pass the address of deployed library to the contract factory of contract. async function main() { const signers = await ethers....
Nitesh Sawant's user avatar
2 votes
Accepted

Why does uniswap V2 re-read duplicate data? (Gas optimization)

The CALLER operation which is reading the msg.sender global variable costs 2. While MLOAD/MSTORE operations which are memory operations (storage where local variables are stored) costs 3. https://...
Zig Balthazar's user avatar
2 votes

console.log output on live network

Use Events for that. contract BookStore { event Hello(string indexed bello); function hello() external { emit Hello("bello"); } } For more info about the events read this: https://...
DevABDee's user avatar
  • 473
2 votes

console.log output on live network

You can not see the console.log on testnet/mainnet. If your want the logs for testing, you could use events. The events are visible on chain. Or you could use a forked network locally and see the ...
donoso.eth's user avatar
  • 1,493
2 votes
Accepted

How do i deploy a contract on chain using bytecode

It's possible to write a Solidity smart contract that takes a creation bytecode as input and then deploys a child smart contract using that creation bytecode via CREATE1 or CREATE2. For the sake of ...
Ahmed Ihsan Tawfeeq's user avatar
2 votes
Accepted

What is block.coinbase in solidity?

block.coinbase (address payable): current block miner’s address https://docs.soliditylang.org/en/v0.8.19/units-and-global-variables.html#block-and-transaction-properties
Henry Gagnier's user avatar
1 vote

Unable to use usdt token inside contract

For every token to send funds via any app, we(owner) of the sender account should give allowance to the receiver account, if this is not done then the transaction would fail for sure.
ShivaPendem's user avatar
1 vote
Accepted

Unable to use usdt token inside contract

It's possible that the error is caused by the fact that USDT doesn't follow the ERC20 standard (the function transferFrom doesn't return true/false). What you can try to do is make an interface for it:...
0xSanson's user avatar
  • 3,249
1 vote

Does data written into blockchain increases with gas usage?

not only storing data use gas. Each process is a sum of opcodes execution. The most expensive opcodes are when you store data. to sum 2 numbers for example costs 3 gas. the fact you process something ...
Catalin's user avatar
  • 436
1 vote

Stuck in a loop problem, cannot figure out the solution

Try this: contract HelloWorld{ uint8[][] public grid; function makegrid(uint8 row, uint8 col,uint8 value) public { for (uint8 i;i<row;i++){ uint8[] memory temp = new ...
prc's user avatar
  • 486
1 vote
Accepted

Is it safe to use ERC 998 now?

Not safe to use. Please see this page https://eips.ethereum.org/EIPS/eip-998 and the STAGNANT warning at top. This means there is no consensus on this protocol and it is very unlikely that if you ...
William Entriken's user avatar
1 vote
Accepted

How can someone verify that the deployer of a smart contract does not hold a matching private key?

Addresses of smart contracts on Ethereum are not generated as part of a key pair but instead derived from the transaction that created the contract. The creation transaction includes the compiled code ...
fallen_angel's user avatar
1 vote
Accepted

Is it possible to simultaneously call a method from the children's smart contract by the parent's smart contract?

Yes, you can batch multiple transactions in one. just make a for loop, that calls each contracts transfer function. I presume all child contract have the same layout? You could do something like: ...
Nal Luksic's user avatar
  • 1,157
1 vote

console.log output

The logs are going to show up in the terminal where your hardhat node is running EDIT : Oh my bad, you're on goerli. Console.log() is a dev feature that's not available on any live network, you'd ...
Foxxxey's user avatar
  • 4,317
1 vote
Accepted

What is the best way to apply for a Job as a Smart Contract engineer?

You should learn the newer development framework foundry because it has much more advanced testing capabilities and all of the top teams use it. Almost no projects use truffle. Learning how to write ...
Elliot's user avatar
  • 26
1 vote
Accepted

Smart Contract: false Transaction mined but execution failed (Merkle trees)

When you're using the online generator you're using as leaf the address of the caller. In the solidity code you're using instead the hash of the address with the quantity of tokens to mint: bytes32 ...
0xSanson's user avatar
  • 3,249
1 vote

Cannot initialize variable in upgradable smart contract using initialize function

The was just because we should use the ERC1967 Proxy implementation to interact with smart contract functions that will have all the functions of the Token smart contractinstead of using the Token ...
Helmi Trabelsi's user avatar
1 vote

Check if contract already deployed in Brownie

You can use the Project.load() method to try to load the contract from the build/deployments/map.json file. If the contract is not found in the file, an error will be raised.
VX3's user avatar
  • 656
1 vote
Accepted

Can send some data from smart contract to an EOA by Solidity call statement?

Yes you can, but it does not send anything, and the EOA address does not receive anything (because it doesn't have bytecode logic to receive) contract Test { bool public success; bytes public ...
minhhn2910's user avatar
  • 1,760
1 vote
Accepted

Solidity contract implement a interface's method without declaring "IS <InterfaceName>"

I guess your concern is about the cast Building building = Building(msg.sender); with msg.sender being the Hack contract. It won't throw any error even if msg.sender is any other contracts or a random ...
minhhn2910's user avatar
  • 1,760
1 vote

i have been trying to compile the code below but keep geting this TypeError: Operator == not compatible with types string storage ref and bytes32

to check if string value has been changed from default you need to check length of this string. To do this change in your code from: require(questions[_questionNumber] == bytes32(0), "Question ...
0xkornel's user avatar
  • 150
1 vote

Event Listener not triggering after transaction using React & ethers.js

I believe the reason is that contract.on starts when the transaction is already mined. You can try writing contract.on before making the transaction, and a contract.off after you get your event. ...
0xSanson's user avatar
  • 3,249
1 vote

Smart contract transactional historic data

You can either store historical states in your contract or output events. Both a database and the block explorer need your events to display useful information (some debuggers can use stack traces, ...
Markus Schick's user avatar
1 vote

How to call contract function with ethersJs?

Function calls in ethers.js accept an extra 'overrides' parameter’s than can be used to set gas and gas price. For example to set the gasLimit to 100k const getFaucetToken = async () => { await ...
Ismael's user avatar
  • 30.5k

Only top scored, non community-wiki answers of a minimum length are eligible