Network
Launch Date
Consensus
Note
Sepolia
Oct 2021
PoW
Like-for-like representation of Ethereum
Görli
Jan 2019
PoA
Proof-of-Authority
Kiln
Mar 2022
PoS
Post-Merge (for ETH2), shadow fork of the mainnet
Kintsugi
Dec 2021
PoS
DEPRECATED, use Kiln; post-Merge (for ETH2)
Ropsten
Nov 2016
PoW
DEPRECATED, use Sepolia; the Merge to happen on Jun 8, 2022
Rinkeby
Apr 2017
PoA
DEPRECATED, use Görli and Görli Faucet
Kovan
Mar 2017
PoA
DEPRECATED, use Sepolia or Görli
List of active and deprecated Ethereum testnets, including Kintsugi.
Features
Optimistic rollup 
ZK-rollup 
Proof
Uses fraud proofs to prove transaction validity. 
Uses validity (zero-knowledge) proofs to prove transaction validity. 
Capital efficiency
Requires waiting through a 1-week delay (dispute period) before withdrawing funds. 
Users can withdraw funds immediately because validity proofs provide incontrovertible evidence of the authenticity of off-chain transactions. 
Data compression
Publishes full transaction data as calldata to Ethereum Mainnet, which increases rollup costs. 
Doesn't need to publish transaction data on Ethereum because ZK-SNARKs and ZK-STARKs already guarantee the accuracy of the rollup state. 
EVM compatibility
Uses a simulation of the Ethereum Virtual Machine (EVM), which allows it to run arbitrary logic and support smart contracts. 
Doesn't widely support EVM computation, although a few EVM-compatible ZK-rollups have appeared. 
Rollup costs
Reduces costs since it publishes minimal data on Ethereum and doesn't have to post proofs for transactions, except in special circumstances. 
Faces higher overhead from costs involved in generating and verifying proofs for every transaction block. ZK proofs require specialized, expensive hardware to create and have high on-chain verification costs. 
Trust assumptions
Doesn't require a trusted setup. 
Requires a trusted setup to work. 
Liveness requirements
Verifiers are needed to keep tabs on the actual rollup state and the one referenced in the state root to detect fraud. 
Users don't need someone to watch the L2 chain to detect fraud. 
Security properties 
Relies on cryptoeconomic incentives to assure users of rollup security. 
Relies on cryptographic guarantees for security. 
Start building
on Alchemy.
Sign up for free
Start building on Optimism.
Sign up for free
Start building on Arbitrum.
Sign up for free
Start building on Ethereum.
Sign up for free
Start building on Polygon.
Sign up for free
Start building on Starknet.
Sign up for free
Start building on Flow.
Sign up for free
kiln faucet
Get free Kiln ETH.
Start building today
Goerli faucet
Get free Goerli ETH.
Start building today
mumbai faucet
Get free Mumbai Matic.
Start building today
rinkeby faucet
Get free Rinkeby
ETH.
Start building today
Start building on Ethereum.
Get started for free
Start building on Ethereum.
Get started for free
Start building on Flow.
Get started for free
Start building on Polygon.
Get started for free
Start building on Starknet.
Get started for free
Start building on Optimism.
Get started for free
Start building on Solana.
Get started for free
Start building on Solana.
Sign up for beta access
Start building on Solana.
Join the waitlist
Arbitrum logo
Start building on Arbitrum.
Get started for free
Learn
Solidity at
Alchemy
University
Get started today
curl 
https://release.solana.com/v1.10.32/solana-install-init-x86_64-pc-windows-msvc.exe 
--output 
C:\solana-install-tmp\solana-install-init.exe 
--create-dirs
Solana
SOLANA SEAHORSE OVERVIEW

How to Write Solana Programs in Python Using Seahorse

A Python Developer's Guide to Writing Solana Applications
Last Updated:
November 4, 2022
Table of Contents
Table of Contents
Table of Contents

{{get-started-solana}}

Solana is a high-performance blockchain network with smart contract functionality built to scale for global adoption. Solana processes an average of 3,000 transactions per second, and is one of the fastest blockchain protocols. Solana Programs are smart contracts written on the Solana blockchain network used to perform every activity, including token transfers, minting NFTs, and voting on-chain.

This article will explain how to write Solana Programs in Python using the Seahorse development framework from a local development environment and from an online IDE.

What are the main ways to develop programs on Solana?

To develop Solana Programs, you need to learn Rust, build with the Anchor development framework, or use Seahorse, a pythonic development framework for Solana.

Rust is the programming language on which Solana was built, and it is the default web3 programming language that can be used to interact with Solana's Sealevel Runtime. 

Developing on Solana with Anchor

Anchor is a framework used to make Solana application development easier by abstracting the complexities of the Rust language from the average user.

Anchor provides Solana developers with tools like the Interface Definition Language (IDL), Typescript packages that generate clients from the IDL, Rust crates, and Command Line Interface (CLI).

Developing on Solana with Seahorse

Seahorse is a community-led Solana development framework that grants developers the ability to write Solana programs in the Python programming language.

Seahorse allows every program written in Python to have the same safety measures that come with Rust programs. Seahorse is fully compatible with Anchor, and is also interoperable with Rust code.

Python is used in the everyday programming of web applications and machine learning projects, and is the most popular programming language.

Since many developers interested in building blockchain-based applications might already have Python programming skills, they can use Seahorse to build a Solana application without having to learn a brand new programming language (Rust).

How to Use Seahorse with a Local Solana Developer Environment

A platform like Solana Playground is only for building and testing applications quickly and should not be depended on for creating large-scale dapps. To set up the environment needed for building with Seahorse on our local workspace, we are going to install the following:

  1. Rust
  2. The Solana Tool Suite
  3. Node
  4. Anchor
  5. Seahorse

1. Install the Essential Solana Development Tools

To install Rust, the Solana Tool Suite, Node, and Anchor, refer to this tutorial on setting up a local Solana developer environment.

If you're running a Linux-based machine you may need to run the following command to add additional dependencies:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev

2. Install Seahorse

Seahorse depends on Anchor and the Rustfmt to work properly. Because Anchor is already be working on your machine, installing Rustfmt package and Anchor is easy.

Run the following command to add the Rustfmt package:

rustup component add rustfmt 

Run the following command in your terminal to install Seahorse:

Cargo install seahorse-lang.

Run one final command to check the Seahorse was properly installed:

seahorse -- version

3. Generate a Paper Wallet 

Since you already have the Solana Command Line Tools installed, you can create a local "paper" wallet to use while working locally.

Run the following command to verify the Solana CLI tools are installed:  

Solana-keygen - -version 

Then type the next command to generate a new keypair:

Solana-keygen new

Save the details properly so you can start using them in your local environment.

To fund your paper wallet:

Run the solana airdrop 2 command to acquire 2 test SOL tokens

If you want to use an online developer environment to test Seahorse instead of running it locally, a good option is Solana Playground.

How to Set Up Seahorse with Solana Playground

Solana Playground is an online Integrated Development Environment built for jumpstarting Solana application development. 

Solana Playground offers the following prebuilt Crates:

  1. Native (Rust) - for developers who intend to build on Solana without any framework
  2. Anchor (Rust) - for developers to build on Solana in Rust additional tooling
  3. Seahorse (Python) - for Solana developers with experience programming with Python
Solana Playground selection screen for choosing a development framework: Native, Anchor, and Seahorse.

1. Create a New Solana Playground Project

Create a new project on Solana Playground with a name for the directory. After creating a name, a demo project named, FizzBuzz, will appear. This mini dapp is what we will use within this tutorial. 

2. Create A Playground Wallet

You must first generate a Playground Wallet for interacting with your Seahorse programs. The Playground Wallet acts as a test wallet for the application. 

  • Click on the “playground wallet”
  • Select a new wallet
  • Follow the prompts and download the JSON file
Solana Playground interface for creating a new Playground Wallet

3. Get Test SOL Tokens

Type the following commands in the playground terminal to get devnet SOL tokens:

$ connect

The connect command links your test wallet with the project. 

$ solana address

The solana address command prints out your Solana wallet address. We will use this address later to initiate the FizzBuzz app.

$ solana airdrop 2

The solana airdrop command deposits test SOL tokens in your wallet to cover the fees required to execute transactions such as “Build” or “Deploy.”

Solana Playground's FizzBuzz Seahorse dapp project file.

How Seahorse’s Python Components Work

In this section, we will walk through creating the popular but simple FizzBuzz app on-chain. There are three main sections in our code:

  1. The Account
  2. Instruction 1
  3. Instruction 2

1. Account

Executable Accounts are used to define the executable code (smart contract) that runs on the Solana blockchain. In the Accounts definition, you can assign the data types needed in your Solana programs. 

Fizz and Buzz are defined to be Boolean data types, while the “n” variable is an unsigned integer type. 


class FizzBuzz(Account):
  fizz: bool
  buzz: bool
  n: u64

2. Instruction 1

There are other forms of accounts called Built-In Accounts. Most of these built-in accounts are used in calling specific instructions on-chain. 

a. Signer Account

Instructions that require signers need a wallet’s approval. A Signer is the wallet that signs the transaction with the instruction call defined in this part of the code. 


@instructiondef init(owner: Signer): 

The owner keyword is used to hold the value of the Signer’s details. To get the public key of the Signer, you can add this code:


key = owner.key()

b. Empty Account

An empty account type is used to initialize the class of the main Account (FizzBuzz) even though it is initially empty. 


@instruction
def init(owner: Signer, fizzbuzz: Empty[FizzBuzz]):
fizzbuzz.init(payer = owner, seeds = ['fizzbuzz', owner])

By using the Empty keyword, you can construct the class defined in the main Account. When the FizzBuzz account is initialized, the creation fee is paid by the Owner (i.e. the signer of the transaction).

Once that account has been created on-chain, it can not be re-created when called again by the same owner. The seed generated from the initialization is able to identify the original account.

3. Instruction 2

The second instruction call uses the already created accounts with their values. 


@instruction
def do_fizzbuzz(fizzbuzz: FizzBuzz, n: u64):
  fizzbuzz.fizz = n % 3 == 0
  fizzbuzz.buzz = n % 5 == 0
  if not fizzbuzz.fizz and not fizzbuzz.buzz:
	fizzbuzz.n = n
  else:
	fizzbuzz.n = 0

Here is the complete code sample for FizzBuzz: 


# fizzbuzz
# Built with Seahorse v0.1.6
# On-chain, persistent FizzBuzz!
from seahorse.prelude import *
# This is your program's public key and it will update
#automatically when you build the project.
declare_id('9q23KbCZWzeeCoyAdS9JTCeno6gWV9U6stzP7yozYWKh');
 
class FizzBuzz(Account):
  fizz: bool
  buzz: bool
  n: u64
 
@instruction
def init(owner: Signer, fizzbuzz: Empty[FizzBuzz]):
  fizzbuzz.init(payer = owner, seeds = ['fizzbuzz', owner])
 
@instruction
def do_fizzbuzz(fizzbuzz: FizzBuzz, n: u64):
  fizzbuzz.fizz = n % 3 == 0
  fizzbuzz.buzz = n % 5 == 0
  if not fizzbuzz.fizz and not fizzbuzz.buzz:
	fizzbuzz.n = n
  else:
	fizzbuzz.n = 0

Start Building Solana Applications with Python Using Seahorse

Seahorse is a community-led open-source project that is entirely free for public use. Seahorse is currently in beta and many of its features are still yet to be implemented. While it is not production-ready, it can be used to experiment and develop applications on Solana's devnet

With Seahorse, building on Solana with Python is possible and simple. If you're a Python developer interested in learning web3 development, exploring Seahorse with Solana Playground is a safe and fun way to start acquiring skills using Anchor, Rust, and Solana programs.

ALCHEMY SUPERNODE - ETHEREUM NODE API

Scale to any size, without any errors

Alchemy Supernode finally makes it possible to scale blockchain applications without all the headaches. Plus, our legendary support will guide you every step of the way.

Get started for free
Supernode footer
Solana
SOLANA SEAHORSE OVERVIEW

How to Write Solana Programs in Python Using Seahorse

A Python Developer's Guide to Writing Solana Applications
Last Updated:
November 4, 2022
Don't miss an update
Sign up for our newsletter to get alpha, key insights, and killer resources.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Table of Contents
Table of Contents

{{get-started-solana}}

Solana is a high-performance blockchain network with smart contract functionality built to scale for global adoption. Solana processes an average of 3,000 transactions per second, and is one of the fastest blockchain protocols. Solana Programs are smart contracts written on the Solana blockchain network used to perform every activity, including token transfers, minting NFTs, and voting on-chain.

This article will explain how to write Solana Programs in Python using the Seahorse development framework from a local development environment and from an online IDE.

What are the main ways to develop programs on Solana?

To develop Solana Programs, you need to learn Rust, build with the Anchor development framework, or use Seahorse, a pythonic development framework for Solana.

Rust is the programming language on which Solana was built, and it is the default web3 programming language that can be used to interact with Solana's Sealevel Runtime. 

Developing on Solana with Anchor

Anchor is a framework used to make Solana application development easier by abstracting the complexities of the Rust language from the average user.

Anchor provides Solana developers with tools like the Interface Definition Language (IDL), Typescript packages that generate clients from the IDL, Rust crates, and Command Line Interface (CLI).

Developing on Solana with Seahorse

Seahorse is a community-led Solana development framework that grants developers the ability to write Solana programs in the Python programming language.

Seahorse allows every program written in Python to have the same safety measures that come with Rust programs. Seahorse is fully compatible with Anchor, and is also interoperable with Rust code.

Python is used in the everyday programming of web applications and machine learning projects, and is the most popular programming language.

Since many developers interested in building blockchain-based applications might already have Python programming skills, they can use Seahorse to build a Solana application without having to learn a brand new programming language (Rust).

How to Use Seahorse with a Local Solana Developer Environment

A platform like Solana Playground is only for building and testing applications quickly and should not be depended on for creating large-scale dapps. To set up the environment needed for building with Seahorse on our local workspace, we are going to install the following:

  1. Rust
  2. The Solana Tool Suite
  3. Node
  4. Anchor
  5. Seahorse

1. Install the Essential Solana Development Tools

To install Rust, the Solana Tool Suite, Node, and Anchor, refer to this tutorial on setting up a local Solana developer environment.

If you're running a Linux-based machine you may need to run the following command to add additional dependencies:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev

2. Install Seahorse

Seahorse depends on Anchor and the Rustfmt to work properly. Because Anchor is already be working on your machine, installing Rustfmt package and Anchor is easy.

Run the following command to add the Rustfmt package:

rustup component add rustfmt 

Run the following command in your terminal to install Seahorse:

Cargo install seahorse-lang.

Run one final command to check the Seahorse was properly installed:

seahorse -- version

3. Generate a Paper Wallet 

Since you already have the Solana Command Line Tools installed, you can create a local "paper" wallet to use while working locally.

Run the following command to verify the Solana CLI tools are installed:  

Solana-keygen - -version 

Then type the next command to generate a new keypair:

Solana-keygen new

Save the details properly so you can start using them in your local environment.

To fund your paper wallet:

Run the solana airdrop 2 command to acquire 2 test SOL tokens

If you want to use an online developer environment to test Seahorse instead of running it locally, a good option is Solana Playground.

How to Set Up Seahorse with Solana Playground

Solana Playground is an online Integrated Development Environment built for jumpstarting Solana application development. 

Solana Playground offers the following prebuilt Crates:

  1. Native (Rust) - for developers who intend to build on Solana without any framework
  2. Anchor (Rust) - for developers to build on Solana in Rust additional tooling
  3. Seahorse (Python) - for Solana developers with experience programming with Python
Solana Playground selection screen for choosing a development framework: Native, Anchor, and Seahorse.

1. Create a New Solana Playground Project

Create a new project on Solana Playground with a name for the directory. After creating a name, a demo project named, FizzBuzz, will appear. This mini dapp is what we will use within this tutorial. 

2. Create A Playground Wallet

You must first generate a Playground Wallet for interacting with your Seahorse programs. The Playground Wallet acts as a test wallet for the application. 

  • Click on the “playground wallet”
  • Select a new wallet
  • Follow the prompts and download the JSON file
Solana Playground interface for creating a new Playground Wallet

3. Get Test SOL Tokens

Type the following commands in the playground terminal to get devnet SOL tokens:

$ connect

The connect command links your test wallet with the project. 

$ solana address

The solana address command prints out your Solana wallet address. We will use this address later to initiate the FizzBuzz app.

$ solana airdrop 2

The solana airdrop command deposits test SOL tokens in your wallet to cover the fees required to execute transactions such as “Build” or “Deploy.”

Solana Playground's FizzBuzz Seahorse dapp project file.

How Seahorse’s Python Components Work

In this section, we will walk through creating the popular but simple FizzBuzz app on-chain. There are three main sections in our code:

  1. The Account
  2. Instruction 1
  3. Instruction 2

1. Account

Executable Accounts are used to define the executable code (smart contract) that runs on the Solana blockchain. In the Accounts definition, you can assign the data types needed in your Solana programs. 

Fizz and Buzz are defined to be Boolean data types, while the “n” variable is an unsigned integer type. 


class FizzBuzz(Account):
  fizz: bool
  buzz: bool
  n: u64

2. Instruction 1

There are other forms of accounts called Built-In Accounts. Most of these built-in accounts are used in calling specific instructions on-chain. 

a. Signer Account

Instructions that require signers need a wallet’s approval. A Signer is the wallet that signs the transaction with the instruction call defined in this part of the code. 


@instructiondef init(owner: Signer): 

The owner keyword is used to hold the value of the Signer’s details. To get the public key of the Signer, you can add this code:


key = owner.key()

b. Empty Account

An empty account type is used to initialize the class of the main Account (FizzBuzz) even though it is initially empty. 


@instruction
def init(owner: Signer, fizzbuzz: Empty[FizzBuzz]):
fizzbuzz.init(payer = owner, seeds = ['fizzbuzz', owner])

By using the Empty keyword, you can construct the class defined in the main Account. When the FizzBuzz account is initialized, the creation fee is paid by the Owner (i.e. the signer of the transaction).

Once that account has been created on-chain, it can not be re-created when called again by the same owner. The seed generated from the initialization is able to identify the original account.

3. Instruction 2

The second instruction call uses the already created accounts with their values. 


@instruction
def do_fizzbuzz(fizzbuzz: FizzBuzz, n: u64):
  fizzbuzz.fizz = n % 3 == 0
  fizzbuzz.buzz = n % 5 == 0
  if not fizzbuzz.fizz and not fizzbuzz.buzz:
	fizzbuzz.n = n
  else:
	fizzbuzz.n = 0

Here is the complete code sample for FizzBuzz: 


# fizzbuzz
# Built with Seahorse v0.1.6
# On-chain, persistent FizzBuzz!
from seahorse.prelude import *
# This is your program's public key and it will update
#automatically when you build the project.
declare_id('9q23KbCZWzeeCoyAdS9JTCeno6gWV9U6stzP7yozYWKh');
 
class FizzBuzz(Account):
  fizz: bool
  buzz: bool
  n: u64
 
@instruction
def init(owner: Signer, fizzbuzz: Empty[FizzBuzz]):
  fizzbuzz.init(payer = owner, seeds = ['fizzbuzz', owner])
 
@instruction
def do_fizzbuzz(fizzbuzz: FizzBuzz, n: u64):
  fizzbuzz.fizz = n % 3 == 0
  fizzbuzz.buzz = n % 5 == 0
  if not fizzbuzz.fizz and not fizzbuzz.buzz:
	fizzbuzz.n = n
  else:
	fizzbuzz.n = 0

Start Building Solana Applications with Python Using Seahorse

Seahorse is a community-led open-source project that is entirely free for public use. Seahorse is currently in beta and many of its features are still yet to be implemented. While it is not production-ready, it can be used to experiment and develop applications on Solana's devnet

With Seahorse, building on Solana with Python is possible and simple. If you're a Python developer interested in learning web3 development, exploring Seahorse with Solana Playground is a safe and fun way to start acquiring skills using Anchor, Rust, and Solana programs.

Solana is a high-performance blockchain network with smart contract functionality built to scale for global adoption. Solana processes an average of 3,000 transactions per second, and is one of the fastest blockchain protocols. Solana Programs are smart contracts written on the Solana blockchain network used to perform every activity, including token transfers, minting NFTs, and voting on-chain.

This article will explain how to write Solana Programs in Python using the Seahorse development framework from a local development environment and from an online IDE.

What are the main ways to develop programs on Solana?

To develop Solana Programs, you need to learn Rust, build with the Anchor development framework, or use Seahorse, a pythonic development framework for Solana.

Rust is the programming language on which Solana was built, and it is the default web3 programming language that can be used to interact with Solana's Sealevel Runtime. 

Developing on Solana with Anchor

Anchor is a framework used to make Solana application development easier by abstracting the complexities of the Rust language from the average user.

Anchor provides Solana developers with tools like the Interface Definition Language (IDL), Typescript packages that generate clients from the IDL, Rust crates, and Command Line Interface (CLI).

Developing on Solana with Seahorse

Seahorse is a community-led Solana development framework that grants developers the ability to write Solana programs in the Python programming language.

Seahorse allows every program written in Python to have the same safety measures that come with Rust programs. Seahorse is fully compatible with Anchor, and is also interoperable with Rust code.

Python is used in the everyday programming of web applications and machine learning projects, and is the most popular programming language.

Since many developers interested in building blockchain-based applications might already have Python programming skills, they can use Seahorse to build a Solana application without having to learn a brand new programming language (Rust).

How to Use Seahorse with a Local Solana Developer Environment

A platform like Solana Playground is only for building and testing applications quickly and should not be depended on for creating large-scale dapps. To set up the environment needed for building with Seahorse on our local workspace, we are going to install the following:

  1. Rust
  2. The Solana Tool Suite
  3. Node
  4. Anchor
  5. Seahorse

1. Install the Essential Solana Development Tools

To install Rust, the Solana Tool Suite, Node, and Anchor, refer to this tutorial on setting up a local Solana developer environment.

If you're running a Linux-based machine you may need to run the following command to add additional dependencies:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev

2. Install Seahorse

Seahorse depends on Anchor and the Rustfmt to work properly. Because Anchor is already be working on your machine, installing Rustfmt package and Anchor is easy.

Run the following command to add the Rustfmt package:

rustup component add rustfmt 

Run the following command in your terminal to install Seahorse:

Cargo install seahorse-lang.

Run one final command to check the Seahorse was properly installed:

seahorse -- version

3. Generate a Paper Wallet 

Since you already have the Solana Command Line Tools installed, you can create a local "paper" wallet to use while working locally.

Run the following command to verify the Solana CLI tools are installed:  

Solana-keygen - -version 

Then type the next command to generate a new keypair:

Solana-keygen new

Save the details properly so you can start using them in your local environment.

To fund your paper wallet:

Run the solana airdrop 2 command to acquire 2 test SOL tokens

If you want to use an online developer environment to test Seahorse instead of running it locally, a good option is Solana Playground.

How to Set Up Seahorse with Solana Playground

Solana Playground is an online Integrated Development Environment built for jumpstarting Solana application development. 

Solana Playground offers the following prebuilt Crates:

  1. Native (Rust) - for developers who intend to build on Solana without any framework
  2. Anchor (Rust) - for developers to build on Solana in Rust additional tooling
  3. Seahorse (Python) - for Solana developers with experience programming with Python
Solana Playground selection screen for choosing a development framework: Native, Anchor, and Seahorse.

1. Create a New Solana Playground Project

Create a new project on Solana Playground with a name for the directory. After creating a name, a demo project named, FizzBuzz, will appear. This mini dapp is what we will use within this tutorial. 

2. Create A Playground Wallet

You must first generate a Playground Wallet for interacting with your Seahorse programs. The Playground Wallet acts as a test wallet for the application. 

  • Click on the “playground wallet”
  • Select a new wallet
  • Follow the prompts and download the JSON file
Solana Playground interface for creating a new Playground Wallet

3. Get Test SOL Tokens

Type the following commands in the playground terminal to get devnet SOL tokens:

$ connect

The connect command links your test wallet with the project. 

$ solana address

The solana address command prints out your Solana wallet address. We will use this address later to initiate the FizzBuzz app.

$ solana airdrop 2

The solana airdrop command deposits test SOL tokens in your wallet to cover the fees required to execute transactions such as “Build” or “Deploy.”

Solana Playground's FizzBuzz Seahorse dapp project file.

How Seahorse’s Python Components Work

In this section, we will walk through creating the popular but simple FizzBuzz app on-chain. There are three main sections in our code:

  1. The Account
  2. Instruction 1
  3. Instruction 2

1. Account

Executable Accounts are used to define the executable code (smart contract) that runs on the Solana blockchain. In the Accounts definition, you can assign the data types needed in your Solana programs. 

Fizz and Buzz are defined to be Boolean data types, while the “n” variable is an unsigned integer type. 


class FizzBuzz(Account):
  fizz: bool
  buzz: bool
  n: u64

2. Instruction 1

There are other forms of accounts called Built-In Accounts. Most of these built-in accounts are used in calling specific instructions on-chain. 

a. Signer Account

Instructions that require signers need a wallet’s approval. A Signer is the wallet that signs the transaction with the instruction call defined in this part of the code. 


@instructiondef init(owner: Signer): 

The owner keyword is used to hold the value of the Signer’s details. To get the public key of the Signer, you can add this code:


key = owner.key()

b. Empty Account

An empty account type is used to initialize the class of the main Account (FizzBuzz) even though it is initially empty. 


@instruction
def init(owner: Signer, fizzbuzz: Empty[FizzBuzz]):
fizzbuzz.init(payer = owner, seeds = ['fizzbuzz', owner])

By using the Empty keyword, you can construct the class defined in the main Account. When the FizzBuzz account is initialized, the creation fee is paid by the Owner (i.e. the signer of the transaction).

Once that account has been created on-chain, it can not be re-created when called again by the same owner. The seed generated from the initialization is able to identify the original account.

3. Instruction 2

The second instruction call uses the already created accounts with their values. 


@instruction
def do_fizzbuzz(fizzbuzz: FizzBuzz, n: u64):
  fizzbuzz.fizz = n % 3 == 0
  fizzbuzz.buzz = n % 5 == 0
  if not fizzbuzz.fizz and not fizzbuzz.buzz:
	fizzbuzz.n = n
  else:
	fizzbuzz.n = 0

Here is the complete code sample for FizzBuzz: 


# fizzbuzz
# Built with Seahorse v0.1.6
# On-chain, persistent FizzBuzz!
from seahorse.prelude import *
# This is your program's public key and it will update
#automatically when you build the project.
declare_id('9q23KbCZWzeeCoyAdS9JTCeno6gWV9U6stzP7yozYWKh');
 
class FizzBuzz(Account):
  fizz: bool
  buzz: bool
  n: u64
 
@instruction
def init(owner: Signer, fizzbuzz: Empty[FizzBuzz]):
  fizzbuzz.init(payer = owner, seeds = ['fizzbuzz', owner])
 
@instruction
def do_fizzbuzz(fizzbuzz: FizzBuzz, n: u64):
  fizzbuzz.fizz = n % 3 == 0
  fizzbuzz.buzz = n % 5 == 0
  if not fizzbuzz.fizz and not fizzbuzz.buzz:
	fizzbuzz.n = n
  else:
	fizzbuzz.n = 0

Start Building Solana Applications with Python Using Seahorse

Seahorse is a community-led open-source project that is entirely free for public use. Seahorse is currently in beta and many of its features are still yet to be implemented. While it is not production-ready, it can be used to experiment and develop applications on Solana's devnet

With Seahorse, building on Solana with Python is possible and simple. If you're a Python developer interested in learning web3 development, exploring Seahorse with Solana Playground is a safe and fun way to start acquiring skills using Anchor, Rust, and Solana programs.

Build web3 with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get started for free