Getting Started
To get started with the Solidity SDK, run the following command to create a new project:
Or, install the contracts
package into your existing Solidity project:
The Solidity SDK can be used to build new smart contracts end-to-end, or to add functionality to your own, existing smart contract using extensions.
All functions in the base contracts and extensions can be modified by overriding them.
The Solidity SDK includes base contracts that are fully complete smart contracts that can be customized by overriding functions OR by adding extensions.
1. To start, import and inherit the base contract. You can find the list of all available base contracts here.
2. Base contracts expect certain constructor arguments to function as intended. Implement a constructor for your smart contract and pass the appropriate values to a constructor for the base contract.
3. Now you're all set up! 🎉 Your smart contract now has all the extensions provided by the base contract it inherits and is ready to be deployed to any EVM blockchain of your choice.
Extensions are to be used via inheritance - your project's smart contract will inherit from them.
Additional extensions can be added to existing smart contracts or to the base contracts to add extra functionality and unlocking features in the SDKs and Dashboard.
1. To start, import and inherit the extension. You can find the list of all available extensions here.
Note:
- Some Extensions are Abstract and so require certain functions to be implemented*.
- Some Extensions are Interfaces and so require all the functions to be implemented*.
*implement = write the logic for the function with a matching function signature (matching name, parameters, visibility and return type)
2. Use the functions provided by the Extension to change the behavior of your smart contract.
Inheritance allows you to extend your smart contract's properties to include the parent contract's attributes and properties. The inherited functions from this parent contract can be modified in the child contract via a process known as overriding.
Parent contract: Contract that the inheriting contract is inheriting from.
Child contract: The inheriting contract.
To override a function, to add your own custom logic, simply use the keyword override
when declaring the function, making sure that the function signature matches.
To add the original logic from the parent contract, use the keyword super
.
For example, the ERC721Base
contract has an implementation of the function mintTo
, I could instead override this function to add custom logic
and restrict this function in the myNFT
contract to only allow 1 NFT per wallet: