examples/

directory
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2025 License: MIT

README

Welcome!

To successfully execute these examples you'll need to configure some environment variables. To do so:

  1. Rename the ".env.template" file located at the root of this folder to ".env"
  2. Uncomment, and assign your Sepolia testnet endpoint to the RPC_PROVIDER_URL variable in the ".env" file
  3. Uncomment, and assign your Sepolia websocket testnet endpoint to the WS_PROVIDER_URL variable in the ".env" file
  4. Uncomment, and assign your account address to the ACCOUNT_ADDRESS variable in the ".env" file (make sure to have a few ETH in it)
  5. Uncomment, and assign your starknet public key to the PUBLIC_KEY variable in the ".env" file
  6. Uncomment, and assign your private key to the PRIVATE_KEY variable in the ".env" file

The variables used vary from example to example, you'll see the required ones on each main.go file, usually after a // Load variables from '.env' file comment. To run an example:

  1. Make sure you are in the chosen example directory
  2. Execute go run FILE_NAME.go to run it

Some FAQ answered by these examples

  1. How to deploy an account? How to send a DEPLOY_ACCOUNT_TXN?
    R: See deployAccount
  2. How to use my existing account importing my account address, and public and private keys?
    R: See deployContractUDC, lines 47 and 61.
  3. How to declare a Cairo contract? How to send a DECLARE_TXN?
    R: See simpleDeclare.
  4. How to deploy a smart contract using UDC?
    R: See deployContractUDC.
  5. How to interact with a deployed Cairo contract? How to send an INVOKE_TXN?
    R: See invoke.
  6. How to make multiple function calls in the same transaction?
    R: See invoke, line 31.
  7. How to estimate fees?
    R: See invoke, line 67.
  8. How to generate random public and private keys?
    R: See deployAccount, line 38.
  9. How to get my nonce?
    R: See invoke, line 18.
  10. How to get the transaction receipt?
    R: See invoke, line 89.
  11. How to deploy an ERC20 token?
    R: See deployContractUDC.
  12. How to get the balance of a ERC20 token?
    R: See simpleCall.
  13. How to make a function call?
    R: See simpleCall.
  14. How to read event logs? R: See readEvents.
  15. How to sign and verify a typed data?
    R: See typedData.
  16. How to use WebSocket methods? How to subscribe, unsubscribe, handle errors, and read values from them?
    R: See websocket.

Directories

Path Synopsis
Internal package to set up basic configurations for the examples contained in the 'examples' folder.
Internal package to set up basic configurations for the examples contained in the 'examples' folder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL