watcher-ts/packages/solidity-mapper/test/contracts/TestBytes.sol
Ashwin Phatak a7ec3d8da8
Add APGL license and copyright notices (#212)
* Add license & copyright declarations for add-watcher.

* Add copyright declarations for cache.

* Add copyright declarations for erc20-watcher.

* Add copyright declarations for ipld-eth-client.

* Add copyright declarations for tracing-client.

* Add copyright declarations for uni-watcher.

* Add copyright declarations for solidity-mapper.

* Add copyright declarations for uni-info-watcher.

* Add copyright declarations for util.

* Add copyright declarations for lighthouse-watcher.

* Change license identifier in .sol files.

Co-authored-by: prathamesh0 <prathamesh.musale0@gmail.com>
2021-08-12 15:28:13 +05:30

44 lines
1.4 KiB
Solidity

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.7.0;
contract TestBytes {
// Byte array variables are packed together in a slot as they occupy less than 32 bytes together.
bytes10 bytesTen;
bytes20 bytesTwenty;
// Byte array variable is stored in the next slot as there is not enough space for it in the previous slot.
bytes30 bytesThirty;
// Dynamically sized byte arrays will take the next single slot.
// If data is 32 or more bytes, the main slot stores the value length * 2 + 1 and the data is stored in keccak256(slot).
// Else the main slot stores the data and value length * 2.
// https://docs.soliditylang.org/en/v0.7.4/internals/layout_in_storage.html#bytes-and-string
bytes bytesArray1;
bytes bytesArray2;
// Set variable bytesTen.
function setBytesTen(bytes10 value) external {
bytesTen = value;
}
// Set variable bytesTwenty.
function setBytesTwenty(bytes20 value) external {
bytesTwenty = value;
}
// Set variable bytesThirty.
function setBytesThirty(bytes30 value) external {
bytesThirty = value;
}
// Set variable bytesArray1.
function setBytesArray1(bytes calldata value) external {
bytesArray1 = value;
}
// Set variable bytesArray2.
function setBytesArray2(bytes calldata value) external {
bytesArray2 = value;
}
}