Skip to content

Instantly share code, notes, and snippets.

@ColinPlatt
Created January 10, 2022 15:29
Show Gist options
  • Save ColinPlatt/e47b74e073be0ab22afb78ef8197dc36 to your computer and use it in GitHub Desktop.
Save ColinPlatt/e47b74e073be0ab22afb78ef8197dc36 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.10+commit.fc410830.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;
interface IPointsNFT {
function readSeed(uint256 id) external view returns (uint256);
}
contract pointsData {
struct layerData {
bytes data;
}
mapping(uint256 => layerData) public CellLayerData;
function addDataToLayer(string memory data, uint256 tokenId) external {
CellLayerData[tokenId].data = abi.encodePacked(data);
}
function multiAdd(string[] memory data, uint256[] memory tokenId) external {
require(data.length == tokenId.length);
for (uint256 i=0; i<tokenId.length; i++) {
CellLayerData[tokenId[i]].data = abi.encodePacked(data[i]);
}
}
function readId(uint256 tokenId) external view returns (string memory) {
return abi.decode(CellLayerData[tokenId].data,(string));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment