Skip to content

dreadful-dev/fil-hello-world-actor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Filecoin Smart Contract Template - Hello World Actor

Prerequesites

  1. Lotus locally fvm-m2 branch or Lotus in Docker
  2. Rust 👇
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default nightly
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
rustup target add wasm32-unknown-unknown --toolchain nightly

Actor deployment on Filecoin is different from Ethereum, in that, actor deployment is a two-step process. The first step "installs" the actor in the virtual machine, which you can think of as inserting a flash drive with code on a computer so that you can run it. This is done via the install install-actor command. Once an actor has been installed to the VM, it needs to be created (e.g. instantiated). When created, the Actor runs an initializer method which can be used to set up things like access control for that specific instance of the Actor.

Actor Deployment

cargo build # build the actor

lotus chain install-actor ./target/debug/wbuild/fil_hello_world_actor/fil_hello_world_actor.compact.wasm
# sending message...
# gas limit: 702194416
# waiting for message to execute...
# Actor Code CID: bafk2bzacedyxt7uaygvrsqbwunosk27j4patg3ip52d2hgppj4fbukojvwb2i

# ./lotus chain create-actor bafk2bzacedyxt7uaygvrsqbwunosk27j4patg3ip52d2hgppj4fbukojvwb2i
# sending message...
# waiting for message to execute...
# ID Address: t01001
# Robust Address: t2ht5hlqz55ixnpo3nfmccrpydmyvlaid24lvwh5y

./lotus chain invoke t01001 2
# sending message...
# waiting for message to execute...
# b0hlbGxvIHdvcmxkICMxIQ==   <-- base64 encoded return data
echo "b0hlbGxvIHdvcmxkICMxIQ==" | base64 -d
# oHello world #1!%

Further Reading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%