The Shields API contract makes it simple to work with the Shields design system on-chain.
npm install @areatechnology/shields-apiThe Shields API contract makes it simple to work with the Shields design system on-chain.
To install with Foundry:
``sh`
forge install areatechnology/shields-api
To install with Hardhat or Truffle:
`sh`
npm install @areatechnology/shields-api
Import the ShieldsAPIConsumer contract and inherit it to access ShieldsAPI and all its methods.
`sol
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.
`sol`
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.
`sol`
function getShieldSVG(uint256 shieldId) external view returns (string memory);
Returns an svg string for a Shield with the specified configuration.
`sol`
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.
`sol`
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.
`sol`
function isShieldBuilt(uint256 shieldId) external view returns (bool);
Returns complete information about a Field.
`sol`
function getField(uint16 field, uint24[4] memory colors) external view returns (IFieldGenerator.FieldData memory);
Returns the title for a Field.
`sol`
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.
`sol`
function getFieldSVG(uint16 field, uint24[4] memory colors) external view returns (string memory);
Returns complete information about a Hardware.
`sol`
function getHardware(uint16 hardware) external view returns (IHardwareGenerator.HardwareData memory);
Returns the title for a Hardware.
`sol`
function getHardwareTitle(uint16 hardware) external view returns (string memory);
Returns an svg string for a Hardware with the specified id.
`sol`
function getHardwareSVG(uint16 hardware) external view returns (string memory);
Returns complete information about a Frame.
`sol`
function getFrame(uint16 frame) external view returns (IFrameGenerator.FrameData memory);
Returns the title for a Frame.
`sol`
function getFrameTitle(uint16 frame) external view returns (string memory);
Returns an svg string for a Frame with the specified id.
`sol``
function getFrameSVG(uint16 frame) external view returns (string memory);