Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
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.
2
votes
Accepted
Can an interface extend a struct in Solidity and what would happen as a result?
You can declare a struct inside an interface and use it as a parameter.
pragma solidity ^0.8.0;
interface MyInterface {
struct MyStruct {
string bar;
}
function foo(MyStruct memory …
0
votes
non-state changing functions: if view is not specified, is gas always charged?
If a function is marked as view or pure, it will not modify the state of the contract and no gas will be charged to the caller when it is called.
If the function is not marked as view or pure, but it …
1
vote
Member "store" not found or not visible after argument-dependent lookup in contract
there is no function called store() in contract SimpleStoragePractice.
Changing
function storeToArray(uint _index, string memory _name) public {
ssfpArray[_index].store(_name);
}
to
functi …
1
vote
I`m trying compilate this code and getting Parse error
You're missing a semicolon when you defined MAx_AMOUNT.
this is the line causing the parsing error:
uint256 constant public MAx_AMOUNT = 10000
corrected:
uint256 constant public MAx_AMOUNT = 10000;
0
votes
Why can't I initialize storage array right away?
Your code works perfectly fine!
I added a view function getArray() to get your storage array.
contract Example {
uint256[4] array = [1, 2, 3, 4];
constructor () {}
function getArray() exte …
0
votes
Does everything revert when a transaction runs out of gas when it was executed from another ...
All the changes (including do stuff in ContractA) will be reverted.
However, you won't get reimbursed for the gas used for computations. Miners will collect that gas whether the transaction is valid o …
0
votes
How can I transfer eth from an account wallet to a smart contract
In order to send or receive Ether, you must declare a function with the keyword payable . By applying the following changes:
function subscribe(uint planId, address payable _to) public payable {
P …
0
votes
Division of big numbers in a smart contract
A way to solve this problem:
isFactor?
/ \
yes no
/ \
calculateRent introduce 'x' so that
input - x = factor
…
0
votes
Pick Winner Lottery test throws; Error: Transaction has been reverted by the EVM
random()'s output is an integer with too many digits.
You can check that by setting random() to public and see what it returns.
In other words, if n is the player's number, and x is the random number, …
2
votes
Accepted
How can I use timestamp for comparisons safely?
The 15-second Rule states that if your contract's code does not rely on a time interval of less then 15 seconds, than it is probably safe to use block.timestamp .
If the scale of your time-dependent …
0
votes
Constructor functions
No it doesn't.
The most and obvious reason is that a function can never have the same name as the contract.
Function can only be called at a defined time to perform a specific task and it requires a …
0
votes
nested struct in solidity
be this:
struct UserInfo{
Pdetails pdetails;
Addr addr;
uint id;
}
Your map will be this:
mapping(uint => UserInfo) idToUserInfo
Now sum it all up:
pragma solidity …
0
votes
Pass enum value in mapping
You want to pass an Enum value of type Category to your TLBs map, so you have to declare category in your struct TLB as Category.
Category[] category; must be as follows Category category;
0
votes
Convert bytes to hexadecimal string in solidity
.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
contract typeCasting{
// hi = 0x6869;
function bytesToString(bytes memory _data) public pure returns (string memory) {
string …
1
vote
Why are we using payable modifiers in both the ERC20 transferFrom and approve functions?
The payable keyword is required for functions and addresses to be able to receive Ether.
By declaring it in transferFrom() and approve(), you are not only able to pay a contract with your ERC20 token, …