Smart Contracts

Development

The most popular Browser-Based IDE for Solidity development is Remix. It is easy to install and use, and it also offers a feature to connect your MetaMask wallet to a contract in the development phase and test it in a real-life-like environment.

Most local IDEs have Solidity plugins or extensions with syntax highlighting. For example, many Solidity developers use Visual Studio Code with additional Solidity plugins.

Truffle and Ganache provide a more comprehensive environment with automated testing, private virtual EVM network deployment, and dummy accounts to interact with.

Hardhat is another popular environment for developing, testing, and deploying smart contracts written in Solidity for EVM chains.

Testing

Ganache is a tool to spin up a private EVM blockchain to test smart contract behavior in a simulated environment.

Solhint is a tool for spotting common mistakes and security flaws and suggesting best practices and style.

Deployment

Smart contracts must be deployed on the blockchain to become accessible.

We recommend using Hardhat as it is one of the most used tools, and there are plenty of tutorials on using it. First, configure Hardhat to use the LightLink Pegasus network. To do this, install Hardhat, create the project, find the hardhat.config.ts file, and change the network parameters:

const config: HardhatUserConfig = {
 solidity: {
   version: '0.8.17',
 },
 networks: {
   // for mainnet
   'lightlink-mainnet': {
     url: 'https://replicator.phoenix.lightlink.io/rpc/v1',
     accounts: [process.env.WALLET_KEY as string],
     gasPrice: 1000000000,
   },
   // for testnet
   'lightlink-testnet': {
     url: 'https://replicator.pegasus.lightlink.io/rpc/v1',
     accounts: [process.env.WALLET_KEY as string],
     gasPrice: 1000000000,
   },
   // for local dev environment
   'base-local': {
     url: 'http://localhost:8545',
     accounts: [process.env.WALLET_KEY as string],
     gasPrice: 1000000000,
   },
 },
 defaultNetwork: 'hardhat',
};

To deploy the contract, put the network argument in the final command:

npx hardhat run scripts/deploy.ts --network lightlink-testnet

Please read the official documentation for more examples of installing and using Hardhat.

Verification

The contracts can be manually verified using Blockscout Explorer (Mainnet, Testnet). Verification ensures that the deployed bytecode matches the human-readable Solidity code, confirming that the developers are not attempting to deceive users.

Additionally, developers can verify the code using IDE plugins. An example is the Hardhat Verifier plugin, which can be used with the following code:

customChains: [
  {
    network: 'phoenix',
    chainId: 1890,
    urls: {
      apiURL: 'https://phoenix.lightlink.io/api',
      browserURL: 'https://phoenix.lightlink.io',
    },
  },
  {
    network: 'pegasus',
    chainId: 1891,
    urls: {
      apiURL: 'https://pegasus.lightlink.io/api',
      browserURL: 'https://pegasus.lightlink.io',
    },
  },
],

Last updated