This week’s challenges were quite open-ended and interesting.
The first challenge was about multisig wallet.
Learnt about meta transactions and off-chain signature-based shared wallet amongst different signers.
In general, the transactions are processed on-chain. But this being a shared wallet, we used off-chain Signature-Based multi sig-wallet.
Once the packed hash(packed hash (bytes32) is a way to represent a specific function call with its parameters as a single hash value) is generated, it can be signed by one of the signers associated with the Multisig wallet. This signature serves as a proof that the signer has authorised the execution of the corresponding function call with the specified parameters. The signature is then added to an array of signatures (bytes[] memory signatures), which contains all the signatures collected so far for the current transaction.
For the challenge, the generation of the packed hash was done off-chain. The packed hash included transaction details like value, data, nonce, chainId, etc. We were able to add and remove signers and based on the number of signers we could also set the number of signs required to process a transaction properly.
The second challenge was a SVG NFT challenge. SVG NFTs are NFTs with all their data on-chain, where usually NFTs store the data on IPFS.
SVG NFTs are also seen in projects like the Bored Ape Yacht Club which uses SVG NFTs to represent unique digital apes that have become highly popular collectibles,Gaming projects, such as Axie Infinity uses SVG NFTs to represent unique in-game creatures, Digital music-related SVG NFTs,Uniswap has launched LP as SVG NFTs in v3 implementation as well.
// SVG NFT data which is dynamic as the trait type 'color' and 'chubbiness' changes
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "not exist");
string memory name = string(abi.encodePacked('Loogie #',id.toString()));
string memory description = string(abi.encodePacked('This Loogie is the color #',color[id].toColor(),' with a chubbiness of ',uint2str(chubbiness[id]),'!!!'));
string memory image = Base64.encode(bytes(generateSVGofTokenById(id)));
return
string(
abi.encodePacked(
'data:application/json;base64,',
Base64.encode(
bytes(
abi.encodePacked(
'{"name":"',
name,
'", "description":"',
description,
'", "external_url":"https://burnyboys.com/token/',
id.toString(),
'", "attributes": [{"trait_type": "color", "value": "#',
color[id].toColor(),
'"},{"trait_type": "chubbiness", "value": ',
uint2str(chubbiness[id]),
'}], "owner":"',
(uint160(ownerOf(id))).toHexString(20),
'", "image": "',
'data:image/svg+xml;base64,',
image,
'"}'
)
)
)
)
);
}
This allows you to generate SVGs
function generateSVGofTokenById(uint256 id) internal view returns (string memory) {
string memory svg = string(abi.encodePacked(
'<svg width="400" height="400" xmlns="http://www.w3.org/2000/svg">',
renderTokenById(id),
'</svg>'
));
return svg;
}
That’s all about this week.
Currently working on the project ideation and will try to finalize a project idea before the deadline.
