Skip to content

Commit ca19ca3

Browse files
author
Yash Agrawal
committed
feat: add view function to encode params
1 parent 34bc2fb commit ca19ca3

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

contracts/SBTToken.sol

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,23 @@ contract SBTToken is ISBTToken, ERC721EnumerableUpgradeable {
218218
);
219219
}
220220

221+
function encodeMetadata(
222+
string memory name,
223+
string memory description,
224+
StringAttribute[] memory stringAttributes,
225+
NumberAttribute[] memory numberAttributes,
226+
string memory tokenUriImage
227+
) public pure override returns (bytes memory) {
228+
return
229+
abi.encode(
230+
name,
231+
description,
232+
tokenUriImage,
233+
stringAttributes,
234+
numberAttributes
235+
);
236+
}
237+
221238
function tokenURI(
222239
uint256 tokenId
223240
) public view override returns (string memory) {

contracts/interfaces/ISBTToken.sol

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ interface ISBTToken {
7878
string memory tokenURIImage
7979
) external;
8080

81+
/*
82+
* @dev Get the NFT metadata in encoded format.
83+
* @param name The name of the NFT.
84+
* @param description The description of the NFT.
85+
* @param stringAttributes The array of all the string attributes.
86+
* @param numberAttributes The array of all the number attributes.
87+
* param tokenUriImage The token image data or url.
88+
* @return bytes The encoded metadata bytes.
89+
*/
90+
function encodeMetadata(
91+
string memory name,
92+
string memory description,
93+
StringAttribute[] memory stringAttributes,
94+
NumberAttribute[] memory numberAttributes,
95+
string memory tokenUriImage
96+
) external pure returns (bytes memory);
97+
8198
/*
8299
* @dev get token ids by owner
83100
* @param _owner owner address

0 commit comments

Comments
 (0)