Questions tagged [time]
The time tag has no usage guidance.
29 questions
0
votes
1
answer
70
views
API for ETH to USD based on time and date
Does anyone know an API that will work based on any period of time. An API where I can put the year, month, day and time and it will give me the ETH to USD conversion at that moment?
0
votes
1
answer
41
views
Simulating the passing of time in forge test for a timelocked contract?
Context
I wrote a contract that aims to raise uint256 investmentTarget funds, within a time period of uint32 private _raisePeriod; after the constructor has been initialised at _startTime = block....
1
vote
1
answer
26
views
How can I check if the day is Valentine’s Day every year?
Happy Valentine’s Day fellow nerds! This year for Valentine’s Day I want to mint my gf a valentine NFT. Since I’m building it I want to turn it into an NFT project that is free to mint for the public ...
0
votes
1
answer
203
views
How to advance blocks in a Hardhat test that uses block.timestamp?
I have this code for a Voting smart contract test:
it("Should return true if end time is less than the current timestamp", async function () {
const { votingSmartContract } = await ...
1
vote
2
answers
2k
views
How to set the timeout for provider http RPC requests in the ethers
I am using JsonRpcProvider in ethers V6. I am sending requests to node like getBlocknumber, getBalance ,sendTransaction etc through JsonRpcProvider. I want to set the response timeout for the requests ...
0
votes
1
answer
30
views
Is blockchain a hard or soft real-time system?
The question is not strictly related to Ethereum. I was wondering if blockchain is considered a hard or soft real-time system? Hard real-time systems are those that have to meet hard deadlines ...
5
votes
2
answers
3k
views
How to work with block timestamps in ethers and hardhat?
I have a time-dependent contract that has two require statements
function launch(uint256 _goal, uint32 _startAt, uint32 _endAt) external {
require(_startAt >= block.timestamp, "...
0
votes
2
answers
87
views
Don't understand why this overflows revert
I have a timelock on an ERC20 contract, from year 0 to 9, it works until year 4, but from year 5 onwards it reverts. It fails both on minting and checking (Using 52 seconds intead of weeks for testing)...
0
votes
0
answers
16
views
timeintervals in Solidity [duplicate]
Is there a way to do something at each time interval in solidity without having to write and sign a transaction (paying gas) each time the interval passed.
For example. Say I have a glass of eWater on ...
2
votes
2
answers
155
views
How to simulate time on testnet?
I deployed contracts to kovan testnet, but I have certain places where there is a 1 week duration. How do I speed up time on testnet so I can easily test these things? (For example speeding it up to ...
0
votes
3
answers
311
views
How to setup a timer for a NFT? [duplicate]
I want to create a nft ERC721 that after 30 days it will be autoburned. How I can achive this?
0
votes
1
answer
165
views
Time-based token distribution in smart contract
Say I have a smart contract for exchanging 6 Token_A with 6 Token_B with an additional time condition when only 1 exchange can happen every 1 month (we don't care about msg.sender here. we can assume ...
2
votes
2
answers
412
views
how to deploy the smart contract in brownie
Error: Final argument must be a dict of transaction parameters that includes a `from` field specifying the address to deploy from
Terminating local RPC client...
smart contract:
pragma solidity ^0.5....
0
votes
1
answer
81
views
How can I advance time when testing on Rinkeby network?
I've successfully deployed my contract to Rinkeby. Testing on Remix everything worked fine. I'm now writing some tests in Javascript but I don't know how to advance time to test functions in a ...
2
votes
1
answer
862
views
Is it better practice to use smaller uint sizes when applicable?
My understanding of uint sizes is that smaller sizes will decrease gas costs. In my current dapp I'm building, I am dealing with time, for which it seems that uint32 will be plenty for my purposes (...
0
votes
1
answer
146
views
Use scheduler in smart contract solidity
I am looking for a way to automate the execution of a function.
Here is a very simple example of a function that will change the state of a boolean variable.
pragma solidity ^0.8.2;
contract Test{
...
0
votes
0
answers
129
views
Managing time increments in Solidity
Say I want to do a simple operation where a value x is automatically doubled after 1 hour. I want the contract to automatically check that it is time to double the value without needing to explicitly ...
0
votes
0
answers
150
views
Get hour of day in Solidity?
What is the most simple way to get hour of the day in Solidity? Will this work? for example creating a condition that works only when it's past 17:00 during that day?
if(hour > 17) { //yay this is ...
1
vote
1
answer
3k
views
Is it possible to create a time based nft where there is a fixed expiry date?
I'm looking to create a set where after a set period of time (a week, a month, a year) the token expires and all its value is wiped. Is it possible to do this and if so how?
0
votes
1
answer
51
views
I need to understand a line of code inside a contract => startTime: _startTime == 0 ? currentTime() : _startTime
I am reading a contract from this location :
https://gist.github.com/rstormsf/7cfb0c6b7a835c0c67b4a394b4fd9383
I am not able to understand the logic in the code line 72
startTime: _startTime == 0 ? ...
2
votes
1
answer
1k
views
Can block.timestamp value change during execution?
I'm facing a doubt while developing an Smart Contract.
I was getting current date from block.timestamp several times inside a function.
Could this value change during an Smart Contract execution?
Or ...
0
votes
2
answers
2k
views
how estimate average time for transactions to smart contract
I have created a decentralized application on the Ethereum Blockchain network. This application receives data from different addresses on the blockchain network and saves this data in the blockchain ...
54
votes
6
answers
41k
views
Time-dependent tests with Hardhat?
For Ganache, there are several solutions.
What about Hardhat? They implemented their own local blockchain, Hardhat Network, which is different to Ganache.
2
votes
1
answer
276
views
Why does Solidity not use the years keyword?
Solidity has keywords like seconds, minutes, hours, days and weeks that are used to specify units of time.
Why do they not have years?
4
votes
3
answers
1k
views
Can the block number be set back in ganache?
I know about tools like ganache-time-traveler that let you advance the block number.
But is it possible to go back to a lower value?
0
votes
1
answer
131
views
What are some practical considerations for leap seconds?
From the solidity docs on time units:
Take care if you perform calendar calculations using these units, because not every year equals 365 days and not even every day has 24 hours because of leap ...
1
vote
1
answer
1k
views
How do I add 7 years to a current time expressed as a block.timestamp?
Being new to solidity, I find the docs on the Internet very confusing.
I simply want to add 7 years to a
uint timeInSevenYearsFromNow = (block.timestamp).add(????);
What is the value of ???? and ...
3
votes
4
answers
3k
views
Is there any library to estimate timestamp of future block?
I am in need of a library that estimates a date or some sort of timestamp when fed with a future block number (on mainnet or any major testnet).
For instance, https://etherscan.io/block/countdown/...
3
votes
1
answer
952
views
In truffle5, how to manipulate time with evm_increaseTime?
I am using truffle 5 and ganache-cli. I've imported increaseTime as
import increaseTime from './helper/increaseTime';
and the increaseTime.js file is like this
export default function increaseTime(...