The Shields API contract makes it simple to work with the Shields design system on-chain.
To install with Foundry:
forge install areatechnology/shields-apiTo install with Hardhat or Truffle:
npm install @areatechnology/shields-apiImport the ShieldsAPIConsumer contract and inherit it to access ShieldsAPI and all its methods.
import "@areatechnology/shields-api/contracts/ShieldsAPIConsumer.sol";
contract MyContract is ShieldsAPIConsumer {
function myFunction() public {
// Any methods in the ShieldsAPI contract can be accessed this way
string memory svg = ShieldsAPI.getShieldSVG(1);
}
}Returns complete information about a Shield in the Shields collection.
function getShield(uint256 shieldId) external view returns (IShields.Shield memory);Returns an svg string for a Shield in the Shields collection. If unbuilt, the SVG will be of a Shield Badge.
function getShieldSVG(uint256 shieldId) external view returns (string memory);Returns an svg string for a Shield with the specified configuration.
function getShieldSVG(uint16 field, uint24[4] memory colors, uint16 hardware, uint16 frame) external view returns (string memory);Returns an svg string for a Shield with the specified configuration.
function getShieldSVG(uint16 field, uint24[4] memory colors, uint16 hardware, uint16 frame) external view returns (string memory);Returns true if the Shield with the specified id has been built in the Shields collection.
function isShieldBuilt(uint256 shieldId) external view returns (bool);Returns complete information about a Field.
function getField(uint16 field, uint24[4] memory colors) external view returns (IFieldGenerator.FieldData memory);Returns the title for a Field.
function getFieldTitle(uint16 field, uint24[4] memory colors) external view returns (string memory);Returns an svg string for a Field with the specified id and colors.
function getFieldSVG(uint16 field, uint24[4] memory colors) external view returns (string memory);Returns complete information about a Hardware.
function getHardware(uint16 hardware) external view returns (IHardwareGenerator.HardwareData memory);Returns the title for a Hardware.
function getHardwareTitle(uint16 hardware) external view returns (string memory);Returns an svg string for a Hardware with the specified id.
function getHardwareSVG(uint16 hardware) external view returns (string memory);Returns complete information about a Frame.
function getFrame(uint16 frame) external view returns (IFrameGenerator.FrameData memory);Returns the title for a Frame.
function getFrameTitle(uint16 frame) external view returns (string memory);Returns an svg string for a Frame with the specified id.
function getFrameSVG(uint16 frame) external view returns (string memory);