// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; contract UsernameSVG is Ownable { string public description = "Username SVGs with embedded usernames"; function generate(string memory username) public view returns (string memory) { string memory svg = string(abi.encodePacked( '', '', '', '', '', '', '', '', '', '', username, '', '', '', '', '', '', '', '', '', '' )); string memory json = Base64.encode(bytes(string(abi.encodePacked( '{"name": "', username, '", "description": "', description, '", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(svg)), '"}' )))); return string(abi.encodePacked('data:application/json;base64,', json)); } function setDescription(string memory _description) public onlyOwner { description = _description; } }