Skip to content

Instantly share code, notes, and snippets.

@BedrosovaYulia
Last active September 2, 2023 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BedrosovaYulia/4c0c7eaa56ac51c0a79c5f2032123c36 to your computer and use it in GitHub Desktop.
Save BedrosovaYulia/4c0c7eaa56ac51c0a79c5f2032123c36 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
contract StorageToStorage {
struct Transcoder {
uint256 cumulativeRewards;
uint256 cumulativeFees;
}
mapping(address => Transcoder) public transcoders;
Transcoder public s;
function setTranscoder(address a, uint256 r, uint256 f) public{
Transcoder memory t;
t.cumulativeFees = f;
t.cumulativeRewards = r;
transcoders[a] = t;
}
function clearTranscoder(address a) public{
Transcoder storage t = transcoders[a];
t.cumulativeFees = 0;
t.cumulativeRewards = 0;
}
function setS(uint256 r, uint256 f) public{
Transcoder memory t;
t.cumulativeFees = f;
t.cumulativeRewards = r;
s = t;
}
function clearS() public {
Transcoder storage t = s;
t.cumulativeFees = 0;
t.cumulativeRewards = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment