bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 13쪽 중 5쪽
nto and ERC token standards and token development on Lisk.
📄️
Deploying a new ERC-20 token on Lisk
A guide on how to deploy a new ERC-20 token on Lisk.
📄️
Deploying a new ERC-721 token on Lisk
A guide on how to deploy a new ERC-721 token on Lisk.
📄️
Deploying a new ERC-1155 token on Lisk
A guide on how to deploy a new ERC-1155 token on Lisk.
## /category/using-oracle-data
📄️
...with RedStone (Pull)
A guide on using RedStone Pull to access real-world data such as asset prices, directly from your smart contracts on the Lisk blockchain.
📄️
...with RedStone (Push)
A guide on using RedStone Push to access real-world data such as asset prices, directly from your smart contracts on the Lisk blockchain.
## /guides/run-a-lisk-node
On this page
This tutorial will walk you through setting up your own
Lisk Node
with Docker.
For instructions to run a Lisk node from source, please check the instructions detailed in the
Lisk Node
GitHub repository.
Objectives
By the end of this tutorial you should be able to:
Deploy and sync a Lisk node
Prerequisites
caution
Running a node is time consuming, resource expensive, and potentially costly. If you don't already know why you want to run your own node, you probably don't need to.
If you're just getting started and need an RPC URL, you can use our free endpoints:
Mainnet
:
https://rpc.api.lisk.com
Testnet (Sepolia)
:
https://rpc.sepolia-api.lisk.com
Note:
Our RPCs are rate-limited, they are not suitable for production apps.
If you're looking to harden your app and avoid rate-limiting for your users, please check out one of our
partners
.
System requirements
We recommend you the following hardware configuration to run a Lisk L2 node:
A modern multi-core CPU with good single-core performance.
A minimum of 16 GB RAM (32 GB recommended).
A locally attached NVMe SSD drive.
Adequate storage capacity to accommodate both the snapshot restoration process (if restoring from snapshot) and chain data, ensuring a minimum of (2 * current_chain_size) + snapshot_size + 20%_buffer.
If running with Docker, please install Docker Engine version
27.0.1
or higher.
Note: If utilizing Amazon Elastic Block Store (EBS), ensure timing buffered disk reads are fast enough in order to avoid latency issues alongside the rate of new blocks added to Base during the initial synchronization process;
io2 block express
is recommended.
Usage
note
It is now possible to run the Lisk nodes with the
--op-network
flag on the
op-geth
execution client.
It is still not possible to run the Lisk nodes with the
--chain
flag on the
op-reth
execution client.
Clone the Repository
git
clone https://github.com/LiskHQ/lisk-node.git
cd
lisk-node
Docker
Ensure you have an Ethereum L1 full node RPC available (not Lisk), and set the
OP_NODE_L1_ETH_RPC
and the
OP_NODE_L1_BEACON
variables (within the
.env.*
files, if using docker-compose).
If running your own L1 node, it needs to be synced before the Lisk node will be able to fully sync.
Please ensure that the environment file relevant to your network (
.env.sepolia
, or
.env.mainnet
) is set for the
env_file
properties within
docker-compose.yml
.
By default, it is set to
.env.mainnet
.
We currently support, running either the
op-geth
or the
op-reth
nodes alongside the
op-node
.
By default, we run the
op-geth
node. If you would like to run the
op-reth
node instead, please set the
CLIENT
environment variable to
reth
before starting the node.
note
The
op-reth
client can be built in either the
maxperf
(default) or
release
profile.
To learn more about them, please check reth's documentation on
Optimizations
.
Please set the
RETH_BUILD_PROFILE
environment variable accordingly.
Unless you are building the
op-reth
client in
release
profile, please ensure that you have a machine with 32 GB RAM.
Additionally, if you have the Docker Desktop installed on your system, please make sure to set Memory limit to a minimum of 16 GB.
It can be set under
Settings -> Resources -> Resource Allocation -> Memory limit
.
Run:
important
To run the node on Lisk Sepolia, first patch the Dockerfile(s) with:
git
apply dockerfile-lisk-sepolia.patch
with
op-geth
execution client:
docker
compose up
--build
--detach
or, with
op-reth
execution client:
CLIENT
=
reth
RETH_BUILD_PROFILE
=
maxperf
docker
compose up
--build
--detach
You should now be able to
curl
your Lisk node:
curl
-s
-d
'{"id":0,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest",false]}'
\
-H
"Content-Type: application/json"
http://localhost:8545
Syncing
Sync speed depends on your L1 node, as the majority of the chain is derived from data submitted to the L1.
You can check your syncing status using the
optimism_syncStatus
RPC on the
op-node
container.
Example:
command -v jq &> /dev/null || { echo "jq is not installed" 1>&2 ; }
echo Latest synced block behind by: \
$((($( date +%s )-\
$( curl -s -d '{"id":0,"jsonrpc":"2.0","method":"optimism_syncStatus"}' -H "Content-Type: application/json" http://localhost:7545 |
jq -r .result.unsafe_l2.timestamp))/60)) minutes
Snapshots
note
Snapshots are available for both
op-geth
and
op-reth
clients:
op-geth
supports both export and datadir snapshots
op-reth
only supports datadir snapshots
All snapshots are from archival nodes
Snapshot types:
export
: small download size, slow to restore from, data is verified during restore (
op-geth
only)
datadir
: large download size, fast to restore from, no data verification during restore
To enable auto-snapshot download and application, set the
APPLY_SNAPSHOT
environment variable to
true
when starting the node:
APPLY_SNAPSHOT
=
true
docker
compose up
--build
--detach
To specify the client and snapshot type, set both the
CLIENT
and
SNAPSHOT_TYPE
environment variables:
# For op-geth with export snapshot (default)
APPLY_SNAPSHOT
=
true
CLIENT
=
geth
SNAPSHOT_TYPE
=
export
docker
compose up
--build
--detach
# For op-geth with datadir snapshot
APPLY_SNAPSHOT
=
true
CLIENT
=
geth
SNAPSHOT_TYPE
=
datadir
docker
compose up
--build
--detach
# For op-reth (only supports datadir)
APPLY_SNAPSHOT
=
true
CLIENT
=
reth
SNAPSHOT_TYPE
=
datadir
docker
compose up
--build
--detach
You can also download and apply a snapshot from a custom URL by setting the
SNAPSHOT_URL
environment variable.
Please make sure the snapshot file ends with
*.tar.gz
.
APPLY_SNAPSHOT
=
true
SNAPSHOT_URL
=
<
custom-snapshot-url
>
docker
compose up
--build
--detach
Objectives
Prerequisites
System requirements
Usage
Clone the Repository
Docker
Syncing
Snapshots
## /lisk-l1/legacy-chain-service
On this page
warning
These docs are referring to the previous Lisk chain on L1, which stopped when Lisk migrated to L2 on May 2024.
If you wish to develop on the current Lisk L2 chain, please refer to the developer documentation under the
Guides
category
To access data from the Legacy Lisk L1 chain, please use the legacy chain service available under
https://legacy.lisk.com
.
Usage
How to use the legacy chain service:
Get a
block by height
https://legacy.lisk.com/blocks/<BLOCK_HEIGHT>.json
Get a
transaction by id
https://legacy.lisk.com/transactions/<TRANSACTION_ID>.json
Get an
account by address
https://legacy.lisk.com/accounts/<LEGACY_ACCOUNT_ADDRESS>.json
Get
histories by address
https://legacy.lisk.com/histories/<LEGACY_ACCOUNT_ADDRESS>.csv
Get
tax-platform-friendly histories in CSV format by address
https://legacy.lisk.com/tax?address=<LEGACY_ACCOUNT_ADDRESS>&platform=<PLATFORM>
where
<LEGACY_ACCOUNT_ADDRESS>
is the Lisk L1 address of the format:
lsk**************************************
or
*******************L
(for uninitialized accounts).
and where
<PLATFORM>
is one of: koinly, blockpit, cointracker, coinledger, coinpanda
If a Lisk L1 legacy account (
*******************L
address) was initialized, the entire history including that of the
*******************L
legacy address will be consolidated under the corresponding
lsk
address. The
*******************L
address's history won't be available separately.
INFO: When is a Lisk L1 account initialized?
A Lisk L1 legacy account is considered initialized, if it either has an outgoing transaction on Lisk Core v2, or had performed a
legacy reclaim transaction
on Lisk Core v3/v4, prior to the Lisk L2 migration, which happened end of May 2024, at block height 24,823,618.
Usage
## /lisk-l1/migration-guide
On this page
warning
These docs are referring to the previous Lisk chain on L1, which stopped when Lisk migrated to L2 on May 2024.
If you wish to develop on the current Lisk L2 chain, please refer to the developer documentation under the
Guides
category
How to smoothly migrate any Lisk L1 app to Lisk L2.
Requirements
You need:
A Lisk L1 application built on
Lisk SDK
version 6.0.0 or later.
A basic understanding of
Solidity
.
The smart contract development framework of your choice.
In this guide, we will use the
Foundry
framework.
Project setup
To illustrate the migration process, we will use the
Hello module
from Lisk L1, and migrate it to Lisk L2.
To start with the project migration, first create a new project with Foundry like this:
forge init hello_liskl2
This will create a new folder
hello_liskl2
, which will contain the smart contracts we are going to implement.
cd
hello_liskl2
Module migration
info
Modules in Lisk L1
are re-implemented as
smart contracts in Lisk L2.
To create a new smart contract, create a new file
Hello.sol
under
src/
and add the following content:
hello_liskl2/src/Hello.sol
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.20 and less than 0.9.0
pragma
solidity
^
0.8.20
;
contract
Hello
{
}
Inside the new contract, we will put all the logic that was residing in the Lisk L1
Hello
module before.
Table: Lisk L1/L2 comparison
Description
Lisk L1
Lisk L2
Onchain business logic
Module
Smart contract
Onchain data storage
Stores (onchain)
State variables
Logging to the blockchain
Blockchain Events
Events
State-transition logic triggered by a transaction
Commands
Functions
API
Endpoints
View functions
Internal API
Methods
Functions (+ modifiers)
Logic triggered per block
Lifecycle Hooks
X
1
Storage
Migrate the onchain stores of a module by implementing corresponding state variables in the contract as shown below.
Lisk L1
Lisk L2
Message Store
Counter Store
hello_client/src/app/modules/hello/stores/message.ts
import
{
BaseStore
}
from
'lisk-sdk'
;
export
interface
MessageStoreData
{
message
:
string
;
}
export
const
messageStoreSchema
=
{
$id
:
'/hello/message'
,
type
:
'object'
,
required
:
[
'message'
]
,
properties
:
{
message
:
{
dataType
:
'string'
,
fieldNumber
:
1
,
}
,
}
,
}
;
export
class
MessageStore
extends
BaseStore
<
MessageStoreData
>
{
public
schema
=
messageStoreSchema
;
}
hello_client/src/app/modules/hello/stores/counter.ts
import
{
BaseStore
}
from
'lisk-sdk'
;
export
interface
CounterStoreData
{
counter
:
number
;
}
export
const
counterKey
=
Buffer
.
alloc
(
0
)
;
export
const
counterStoreSchema
=
{
$id
:
'/hello/counter'
,
type
:
'object'
,
required
:
[
'counter'
]
,
properties
:
{
counter
:
{
dataType
:
'uint32'
,
fieldNumber
:
1
,
}
,
}
,
}
;
export
class
CounterStore
extends
BaseStore
<
CounterStoreData
>
{
public
schema
=
counterStoreSchema
;
}
hello_liskl2/src/Hello.sol
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.20 and less than 0.9.0
pragma
solidity
^
0.8.20
;
contract
Hello
{
/** State variables */
// State variable for the Hello messages
mapping
(
address
=>
string
)
public
message
;
// State variable for the message counter
uint32
public
counter
=
0
;
}
Events
Migrate the blockchain events of a module by implementing corresponding events in the contract as shown below.
Lisk L1
Lisk L2
hello_client/src/app/modules/hello/events/new_hello.ts
import
{
BaseEvent
}
from
'lisk-sdk'
;
export
const
newHelloEventSchema
=
{
$id
:
'/hello/events/new_hello'
,
type
:
'object'
,
required
:
[
'senderAddress'
,
'message'
]
,
properties
:
{
senderAddress
:
{
dataType
:
'bytes'
,
fieldNumber
:
1
,
}
,
message
:
{
dataType
:
'string'
,
fieldNumber
:
2
,
}
,
}
,
}
;
export
interface
NewHelloEventData
{
senderAddress
:
Buffer
;
message
:
string
;
}
export
class
NewHelloEvent
extends
BaseEvent
<
NewHelloEventData
>
{
public
schema
=
newHelloEventSchema
;
}
hello_liskl2/src/Hello.sol
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.20 and less than 0.9.0
pragma
solidity
^
0.8.20
;
contract
Hello
{
/** State variables */
// State variable for the Hello messages
mapping
(
address
=>
string
)
public
message
;
// State variable for the message counter
uint32
public
counter
=
0
;
/** Events */
// Event for new Hello messages
event
NewHello
(
address
indexed
sender
,
string
message
)
;
}
State transition logic
Configuration migration
Configuration
The module-specific configurations, which resided in the
config.json
on Lisk L1, are now part of the smart contract itself and are defined as state variables.
hello_liskl2/src/Hello.sol
// Blacklist of words that are not allowed in the Hello message
string
[
]
public
blacklist
=
[
"word1"
,
"word2"
]
;
// Maximum length of the Hello message
uint32
public
maxLength
=
200
;
// Minimum length of the Hello message
uint32
public
minLength
=
3
;
To edit the configuration options of the Hello module, we implement the following functions in the Hello contract:
setBlacklist()
to configure the blacklist of words that are not allowed in the Hello message.
setMinMaxMessageLength()
to configure the minimum and maximum length of the Hello message.
hello_liskl2/src/Hello.sol
// Function to configure the blacklist
function
setBlacklist
(
string
[
]
memory
_newBlackList
)
public
onlyOwner
{
blacklist
=
_newBlackList
;
}
// Function to configure min/max message length
function
setMinMaxMessageLength
(
uint32
_newMinLength
,
uint32
_newMaxLength
)
public
onlyOwner
{
minLength
=
_newMinLength
;
maxLength
=
_newMaxLength
;
}
As seen in the above code snippet, we add the following modifiers to the functions:
public
to make the function callable from outside the contract.
This is a default visibility modifier for functions in Solidity.
onlyOwner
to check that the caller is the owner of the contract.
This is a custom modifier that we need to implement in the contract manually, as shown in the example below.
To set the owner of the contract, we add a new state variable
owner
, and a constructor which sets the
owner
variable to the account address that deploys the contract.
tip
To update the smart contract owner, you can implement a corresponding function
setOwner()
, and use the
onlyOwner
modifier to ensure that only the current owner can call this function.
Finally, we can check for the message sender being the owner of the contract in the
onlyOwner
modifier which is used for the
setBlacklist()
and
setMinMaxMessageLength()
functions.
hello_liskl2/src/Hello.sol
// Address of the contract owner
address
public
immutable owner
;
constructor
(
)
{
// Set the transaction sender as the owner of the contract.
owner
=
msg
.
sender
;
}
/** Modifiers */
// Modifier to check that the caller is the owner of the contract.
modifier
onlyOwner
(
)
{
require
(
msg
.
sender
==
owner
,
"Not owner"
)
;
_
;
}
Verification migration
Verification
To verify the Hello message, we implement custom modifiers in the contract.
Inside the modifiers, we check the length of the message and if it contains any blacklisted words like it was done in the
verify()
method of the Lisk L1 Hello module.
Conveniently check the length of Hello messages in the
validLength
modifier like this:
hello_liskl2/src/Hello.sol
// Validate message length
modifier
validLength
(
string
memory
_message
)
{
require
(
bytes
(
_message
)
.
length
>=
minLength
,
"Message too short"
)
;
require
(
bytes
(
_message
)
.
length
<=
maxLength
,
"Message too long"
)
;
_
;
}
To check if the message contains any blacklisted words, we implement the
validWords
modifier in the contract.
hello_liskl2/src/Hello.sol
// Validate message content
modifier
validWords
(
string
memory
_message
)
{
bytes
memory
whereBytes
=
bytes
(
_message
)
;
for
(
uint
h
=
0
;
h
<
blacklist
.
length
;
h
++
)
{
bool
found
=
false
;
bytes
memory
whatBytes
=
bytes
(
blacklist
[
h
]
)
;
for
(
uint
i
=
0
;
i
<=
whereBytes
.
length
-
whatBytes
.
length
;
i
++
)
{
bool
flag
=
true
;
for
(
uint
j
=
0
;
j
<
whatBytes
.
length
;
j
++
)
if
(
whereBytes
[
i
+
j
]
!=
whatBytes
[
j
]
)
{
flag
=
false
;
break
;
}
if
(
flag
)
{
found
=
true
;
break
;
}
}
require
(
!
found
,
"Message contains blacklisted word"
)
;
}
_
;
}
Execution migration
Execution
To migrate the createHello command execution, we implement the
createHello()
function in the contract.
Inside this function, we save the message of the sender in the
message
mapping under the sender address.
tip
The sender address is a
global variable
in Solidity and can be accessed with
msg.sender
.
Additionally, we increment the Hello message counter by
1
and emit the
NewHello
event, like it was done in the
execute()
method of the Lisk L1 Hello module previously.
The
validMessage()
modifier that we defined above in the
Verification migration
section is used to check if the message is valid before the
createHello()
function is executed.
hello_liskl2/src/Hello.sol
// Function to create a new Hello message
function
createHello
(
string
calldata
_message
)
public
validLength
(
_message
)
validWords
(
_message
)
{
message
[
msg
.
sender
]
=
_message
;
counter
+=
1
;
emit
NewHello
(
msg
.
sender
,
_message
)
;
}
Lisk L1
Lisk L2
hello_client/src/app/modules/hello/commands/create_hello_command.ts
/* eslint-disable class-methods-use-this */
import
{
BaseCommand
,
CommandVerifyContext
,
CommandExecuteContext
,
VerificationResult
,
VerifyStatus
,
}
from
'lisk-sdk'
;
import
{
createHelloSchema
}
from
'../schema'
;
import
{
MessageStore
}
from
'../stores/message'
;
import
{
counterKey
,
CounterStore
,
CounterStoreData
}
from
'../stores/counter'
;
import
{
ModuleConfig
}
from
'../types'
;
import
{
NewHelloEvent
}
from
'../events/new_hello'
;
interface
Params
{
message
:
string
;
}
export
class
CreateHelloCommand
extends
BaseCommand
{
public
schema
=
createHelloSchema
;
private
_blacklist
!
:
string
[
]
;
// eslint-disable-next-line @typescript-eslint/require-await
public
async
init
(
config
:
ModuleConfig
)
:
Promise
<
void
>
{
// Set _blacklist to the value of the blacklist defined in the module config
this
.
_blacklist
=
config
.
blacklist
;
// Set the max message length to the value defined in the module config
this
.
schema
.
properties
.
message
.
maxLength
=
config
.
maxMessageLength
;
// Set the min message length to the value defined in the module config
this
.
schema
.
properties
.
message
.
minLength
=
config
.
minMessageLength
;
}
// eslint-disable-next-line @typescript-eslint/require-await
public
async
verify
(
context
:
CommandVerifyContext
<
Params
>
)
:
Promise
<
VerificationResult
>
{
let
validation
:
VerificationResult
;
const
wordList
=
context
.
params
.
message
.
split
(
" "
)
;
const
found
=
this
.
_blacklist
.
filter
(
value
=>
wordList
.
includes
(
value
)
)
;
if
(
found
.
length
>
0
)
{
context
.
logger
.
info
(
"==== FOUND: Message contains a blacklisted word ===="
)
;
throw
new
Error
(
`
Ill프로젝트로 돌아가기