Questions tagged [code]
The code tag has no usage guidance.
37
questions
0
votes
1
answer
9
views
Creating a local variable in an if statement?
I'm looking at a function that creates a local variable in an if statement. If someone called that function and the condition to the if statement was not triggered, that local variable wouldn't exist, ...
0
votes
2
answers
15
views
Explain this constructor inheritance solidity
Is BranchBridgeAgentFactory the parent contract?
Will there be two different address? Or just one?
pragma solidity ^0.8.0;
contract TestBranchBridgeAgentFactory is BranchBridgeAgentFactory {
/*////...
2
votes
1
answer
69
views
Where in the code of this unstake function is ETH actually transferred?
I am looking at this repo, which is contracts for a decentralized pegged asset issuance system backed by liquid staking tokens like rETH. Specifically, I have a question about the functions unstake in ...
0
votes
0
answers
17
views
Treating two assets as equal in a smart contract that aren't equal
I am auditing a protocol that creates a token yETH representing a basket of liquid staking tokens such as rETH and stETH. I noticed that the protocol treats yETH as if it is 1:1 with ETH when it's ...
0
votes
1
answer
18
views
Can you refer to a contract inside itself?
Sorry this is a very minor question but the following is part of a contract called LibOrders.sol. The function below calls LibOrders.cancelOrder....normally I think you would just put "...
0
votes
0
answers
9
views
What happens if you divide a uint256 by a uint88 using divU64?
I am looking at the following function. It takes a uint256 (ercDebtSocialized) and uses safemath divU64 to divide it by a uint88. I assume this would just throw an error? I unfortunately cannot test ...
0
votes
0
answers
10
views
I accidently deleted the contract in remix [closed]
I accidently deleted the contract in Remix..I do know the contract can I copy and paste that in etherscan?
1
vote
1
answer
51
views
Two people calling this function at exactly the same time
I was looking at Rocket Pool's docs on interacting with other contracts and they included a simple example function that another protocol could use to accept deposits of ETH, forward it to RP, and get ...
0
votes
2
answers
29
views
Can a function call itself?
Can a function call itself...specifically, I am looking at this code and I can't figure out how this could work properly...the parameter vault would be the first parameter in the line that calls ...
1
vote
1
answer
14
views
Can you return something only some of the time with a function in solidity?
I am looking at a function that says it returns two uints, but the return statement is inside an else statement, so obviously there are conditions under which nothing would be returned. Can you have ...
0
votes
1
answer
9
views
Revert inside a for loop
If there is a revert inside a for loop that is inside a function, and the revert is triggered, will the whole function revert?
0
votes
1
answer
33
views
Can I modify a smart contract's code? [duplicate]
I get scammed big time, not proud! The worst? I can see the ETH on a watched only account. I think there's not really withdraw function at all in the code. Can I modify it to withdraw the funds and ...
0
votes
1
answer
11
views
Expected identifier but got ';' ? I am writing a poker game in Solidity and having problems declaring sortedCards as a state variable. Help:)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract NoLimitPoker {
address public dealer;
address public smallBlind;
address public bigBlind;
uint public minBuyIn;
...
0
votes
0
answers
34
views
How to get 3 level chain of referrals and pay commissions to the 3 level up Grand Referrals in solidity smart contract?
I am using the solidity smart contract to make the MLM system
I am facing the issue of storing the grand referrals and sending them the commissions if any address that is purchasing membership has the ...
0
votes
1
answer
16
views
Doubts on computing ETH daily number of active addresses
I am trying to compute the number of daily active addresses from the ETH's blockchain. For this, I am using this mild SQL query:
SELECT
date_trunc('day', block_timestamp) as day,
COUNT(...
0
votes
0
answers
26
views
How is this scam code transferring tokens to the wallet within the code? [duplicate]
Just curious if someone can find the scam wallet in this code. It's somewhere towards the bottom, if you run debug the wallet address slowly starts showing up. It starts as a random part of the ...
1
vote
2
answers
206
views
Does the EVM revert if a call is attempted to an address that doesn't have code?
The following code would revert in high-level Solidity if the provided addr is an EOA or a contract that does not implement MyInterface:
interface MyInterface {
function myFunction() external;
}
...
0
votes
0
answers
14
views
Accessing an internal function in my contract via assembly in another function
I have this block of code that compares hashes of bytes and I would like to convert directly into assembly:
uint skipPointer; // prevents excess search if a match has been found
uint ...
1
vote
2
answers
254
views
How to concatenate 2 strings in Solidity?
Question in the title, how to concatenate 2 strings in Solidity?
Googled and searched here but no luck.
Please help,
Thanks
1
vote
1
answer
173
views
How do I manipulate the elements of a memory array in assembly?
Simple example:
Let's say I have a function that takes a fixed size array, finds the largest number in it, and returns another fixed size array in memory with the largest number as the last index:
...
1
vote
0
answers
25
views
Why two different source code generate same control flow graph in ethereum smart contract?
I analyzed control flow graph of two contracts written in solidity with different source code, one having vulnerability and other after resolving it. https://swcregistry.io/docs/SWC-107#modifier-...
0
votes
0
answers
15
views
How to determine whether the code can add exception handling
Github file: https://github.com/ethereum/go-ethereum/blob/master/rpc/client.go
Code:
// read decodes RPC messages from a codec, feeding them into dispatch.
func (c *Client) read(codec ServerCodec) {
...
0
votes
1
answer
26
views
Explain the idea of an array of contracts in solidity and the implementation of "sfStore" function in the code attached below
SimpleStorage[] public simpleStorageArray;
function createSimpleStorageContract() public {
SimpleStorage simpleStorage = new SimpleStorage();
simpleStorageArray.push(simpleStorage);
}
...
0
votes
1
answer
48
views
Feasibility for Vulnerability Detection in Smart Contracts
I am excited to find out which is more feasible for vulnerability detection in ethereum smart contracts(solidity): Source Code or ByteCode and what's the reason?
0
votes
1
answer
36
views
Ethernaut Challenge Shop
I don't understand why remix doesn't allow me to compile this code, even though the logic is similar to the answers I found on the internet.
The error: from solidity:
MyContract.sol:20:11: TypeError: ...
0
votes
0
answers
633
views
Internal JSON-RPC error. { "code": -32000, "message": "execution reverted"
How can I solve this mistake every time I try to deploy a contract in the testnet. I hope you guys can help me.
This is the code // SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
interface ...
0
votes
0
answers
35
views
How to get the information of 100000 smartcontracts in etherscan
At https://etherscan.io/contractsVerified?filter=opensourcelicense are the addresses of the last 10,000 smart contracts. However, there are many more. I want to get the OpenSourceCode of more than ...
0
votes
0
answers
51
views
How to get the source code of more than 5000 smart contracts using the etherscan.io API
At https://etherscan.io/contractsVerified?filter=opensourcelicense
are the addresses of the last 10,000 smart contracts. However, there are many more. I want to get the OpenSourceCode of contracts for ...
0
votes
1
answer
16
views
solidity doubt error unknown [closed]
ParserError: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition.
--> contracts/college.sol:104:1:
|
104 | }
| ^
1
vote
1
answer
18
views
Where can I find how the Ethereum protocol calculates transaction fees, supply issuance, and other key components?
I would like to learn how different components of the Ethereum protocol are calculated. Where can see how these and other elements?
Is there a code database that a final code source that I can refer ...
1
vote
0
answers
37
views
how import in remix smart contract without source code?
I am trying to call a fallback function on a smart contract that has not verified contract source code, How can I do this?
Thanks in advance
0
votes
1
answer
351
views
Can I put html code as an onChain NFT?
Can I put html code as an on-chain NFT?
I don't want the NFT to be an image, I would like it to hold html code.
e.g the NFT will be Hello world
3
votes
2
answers
3k
views
how to Get All tokens against a specific Walllet Addresse?
Is It Possible to get All tokens against a specific wallet Address , whether it is deployed on a ethereum blockchain , solna , polygone or whatever ?
0
votes
1
answer
279
views
Does address.code return runtime or creation code
You have three options to retrieve bytecode: type(C).runtimeCode which returns the runtime code of a contract, type(C).creationCode which returns the creation code of a contract and address.code which ...
0
votes
1
answer
16
views
Gnosis safe not letting transfer of tokesn
I have an issue with a safe that is a mutli sig and i have a token contract on there that it will not let me send any of the tokens it lets me and my others confirm it but on the execute function it ...
1
vote
0
answers
1k
views
TypeError: Operator * not compatible with types int256 and uint256 --> contracts
Fairly new at this so there's probably an obvious answer. I was just playing around with an interest bearing contract. this below works out fine:
uint interestPerSecond = _interest * (_amount / 1e16); ...
0
votes
1
answer
118
views
Store addresses in bytes variable
I need help with storing a bytes value.
contract StoreBytes {
bytes public addresses;
function addMe() external {
// TODO Add msg.sender to addresses.
}
}
What I want is that msg....