Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

ApeWorX/archive-ape-starknet

Repository files navigation

Quick Start

Plugins for the Starknet Ethereum L2 networks.

Dependencies

  • python3 version 3.8 or greater, python3-dev

Installation

via pip

You can install the latest release via pip:

pip install ape-starknet

via setuptools

You can clone the repository and use setuptools for the most up-to-date version:

git clone https://github.com/ApeWorX/ape-starknet.git
cd ape-starknet
python3 setup.py install

Quick Usage

Account Management

Accounts are used to execute transactions and sign call data. Accounts are smart contracts in Starknet.

You can access accounts using

ape starknet accounts

Learn more about accounts by following the accounts guide.

Testing

Out of the box, ape-starknet comes with development accounts. Access them like this:

from ape import accounts

container = accounts.containers["starknet"]
owner = container.test_accounts[0]

See the guide about Testing to learn more about test accounts and testing with the Starknet plugin.

Contracts

In Starknet, you can declare contract types by publishing them to the chain. This allows other contracts to create instances of them using the deploy system call.

Learn more about contracts by following the contracts guide.

Paying Fees

Starknet fees are currently paid in ETH, which is an ERC-20 on the Starknet chain. To check your account balance (in ETH), use the balance property on the account:

from ape import accounts

acct = accounts.load("Alias")
print(acct.balance)

If your account has a positive balance, you can begin paying fees!

To pay fees, you can manually set the max_fee kwarg on an invoke-transaction:

receipt = contract.my_mutable_method(123, max_fee=2900000000000)

NOTE: If max_fee is not set, it will default to the value returned from the provider's estimate_gas_cost() call. You do not need to call estimate_gas_cost() explicitly.

Mainnet Alpha Whitelist Deployment Token

Currently, to deploy to Alpha-Mainnet, your contract needs to be whitelisted. You can provide your WL token in a variety of ways.

Via Python code:

from ape import project

my_contract = project.MyContract.deploy(token="MY_TOKEN")

Via an Environment Variable:

export ALPHA_MAINNET_WL_DEPLOY_TOKEN="MY_TOKEN"

Development

This project is in development and should be considered a beta. Things might not be in their final state and breaking changes may occur. Comments, questions, criticisms and pull requests are welcomed.