Interact with sandbox from containerised app

Hi Algorand community,

I have a Docker container running my Django app.
I am using the development sandbox which uses Docker as well.

All the guides/tutorials i saw so far have python installed on the client instead, so that “goal” commands can be launched via terminal.

I am using python and pyteal, is there a way to avoid the use of the command line and talk directly to the sandbox container form my containerised app?

you must be using python SDK. to compile or deploy the smart contracts.
You need to configure algod and indexer to connect to your local sandbox environment.

look at connecting your client section in below article:

1 Like

Hi @humblefool thanks for your reply.

I can see how to start the sandbox with testenet network and when i do so the indexer appears disabled

image

do you know if there are tutorials to set this up?

also this tutorial doesnt explain how to create smart contracts, I only found tutorials explaining the interaction with goal commands. Do you know if there are any tutorials on this?

sandbox does not support indexer for testnet because indexer requires a full archival node (which currently takes 2 week to sync).

If you need access to indexer, you either need to run your own archival node and indexer (two weeks to sync and about 2TB of disk), or use an API service: Ecosystem Tools & Projects | Algorand Developer Portal

Hi @fabrice , Thanks for your reply.

So to be clear, when i do ./sandbox testnet up, the container I create is the mean of communication to the testnet? so if i create an account it will persist?
is this the similar process to connect to the mainNet?

I have no issues using algoExplorer for read operation, but going to procudtion will we require to connect to MainNet via downloading a full node?

Just to close this question, the solution is that launching commands on the host from a container is not the way to go.
Instead:

  • you have to use an SDK, python in this case.
  • the sandbox must be connected to the testNet.
  • the sandbox containers and your application containers must be on the same docker network

The sandbox creates a docker network so you have to:

  1. cd ~/sandbox
  2. vi docker-compose.yml
    in the docker compose file, add a networking snippet after service:
    networks:
    algorand_nw:
    ipam:
    config:
    - subnet: 172.10.0.0/16

then add the followings:
a. under the algod conteiner add:
networks:
algorand_nw:
ipv4_address: 172.10.0.100

b. under the other 2 containers add:
networks:
- algorand_nw

  1. Edit your application’s docker compose file and at the top, under service, add:
    networks:
    sandbox_algorand_nw:
    external: true

now add the network under the container details:
networks:
- sandbox_algorand_nw

“sandbox_” is added by the algorand sandbox scripts somewhere, I could not find where.

  1. Add in yout application container the details about the static IP for the algod container:
    extra_hosts:
    • “algorand-sandbox-algod:127.10.0.100”

Now you will have all the containers in the same virtual subnet and the extra host in your application’s container.

This set up requires to use an API service for read operations, or to download a whole test node

Yes, sandbox, like your own node or an API services, are just a mean to access the testnet/mainnet blockchain. If you send a transaction through it, it will stay forever on the blockchain.

1 Like

Thanks to @humblefool and @fabrice for the clarifications that helped me getting to a working solution