Skip to main content

Getting started

Smart contract developer, welcome to the LUKSO documentation! The LUKSO ecosystem offers you a lot of new standards and tools to build more powerful blockchain applications which are - very important - standardised.

As LUKSO is an EVM-based Blockchain, all tools and tutorials for Ethereum also work well for LUKSO. The following tutorial will teach you how to:

If you need more low level information about our contracts, you can check the dedicated contracts section.

Happy coding 🧙

Create Hardhat project​

The first thing to do is to create a new Hardhat project that will use TypeScript:

mkdir lukso-app
cd lukso-app
npx hardhat
# select 'Create a TypeScript project' and
# use the default value for the rest of the setup

Once finished, you have a working Hardhat setup!

Install packages & setup tools​

To work in the best condition possible, we will install libraries that includes tools, helpers and the @lukso/lsp-smart-contracts package.

npm i -D dotenv
npm i -s @lukso/[email protected]

Update your package.json with the following:

package.json
"scripts": {
"build": "hardhat compile --force --show-stack-traces"
},

Create a .env file​

Create a new file at the root of your project called .env with the following content:

warning

The .env file contains sensitive values such as PRIVATE_KEY. Do not commit it to your source code repository!

note

We will populate the values of the .env file later.

.env
PRIVATE_KEY=0x....
UP_ADDR=0x...

We now have a base Hardhat setup that we can use to develop and deploy our smart contracts.

Get testnet LYXt​

To pay for the deployment fees, you need LYXt. You can request some from the LUKSO Testnet faucet

Deploy your contracts on the LUKSO Testnet​

info

By default, the deployment will be to your local network. If you want to deploy to the LUKSO Testnet, you will need to add the LUKSO Testnet network in your hardhat.config.ts.

hardhat.config.ts
// ...
import { NetworkUserConfig } from 'hardhat/types';

import * as dotenv from 'dotenv';
dotenv.config();

// ...

function getTestnetChainConfig(): NetworkUserConfig {
const config: NetworkUserConfig = {
url: 'https://rpc.testnet.lukso.network',
chainId: 4201,
};

if (process.env.PRIVATE_KEY !== undefined) {
config['accounts'] = [process.env.PRIVATE_KEY];
}

return config;
}

// Edit the default config object so it matches this one:
const config: HardhatUserConfig = {
solidity: {
version: '0.8.19',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
typechain: {
outDir: 'typechain-types',
target: 'ethers-v6',
},
networks: {
luksoTestnet: getTestnetChainConfig(),
},
};