• Stars
    star
    184
  • Rank 209,187 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Keeps track of transactions sent via Safe contacts and confirmed transactions. It also keeps track of Ether and ERC20 token transfers to Safe contracts.

Build Status Coverage Status pre-commit Python 3.10 Django 4 Docker Image Version (latest semver)

Safe Transaction Service

Keeps track of transactions sent via Safe contracts. It uses events and tracing to index the txs.

Transactions are detected in an automatic way, so there is no need of informing the service about the transactions as in previous versions of the Transaction Service.

Transactions can also be sent to the service to allow offchain collecting of signatures or informing the owners about a transaction that is pending to be sent to the blockchain.

Swagger (Mainnet version) Swagger (GΓΆerli version)

Index of contents

Setup for development

Use a virtualenv if possible:

python -m venv venv

Then enter the virtualenv and install the dependencies:

source venv/bin/activate
pip install -r requirements-dev.txt
pre-commit install -f
cp .env.dev .env
./run_tests.sh

Setup for development using docker

docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

Setup for production (event indexing)

Since version 3.0.0 transaction service can be configured to rely on event indexing when SafeL2 version is used. Only contracts from v1.3.0 onwards with L2 events will be indexed.

An example environment file can be used for the L2 setup:

cp .env.l2.sample .env

Edit .env file to add ETHEREUM_NODE_URL (on the example a Polygon public node is used) and remember to modify DJANGO_SECRET_KEY to use a strong key. The rest of the configuration does not need to be modified. Then:

docker-compose build --force-rm
docker-compose up

For more parameters check base.py file.

Setup for a custom network

  • If the network is not supported yet contracts can be deployed using the deployment instructions and then a PR should be provided adding the deployment block number and the address (address will be the same for every network).
  • Only ProxyFactory and GnosisSafeL2 must be configured. +L2 must be added to the Safe L2 contract versions, so the service knows the contract can be indexed using events. For us to accept the PR network must be on https://github.com/ethereum-lists/chains .
  • You can always set this up later using the admin panel if your network is not supported, going to the Master Copies and Proxy Factories.
  • We recommend using event indexing for every network where transaction fees are not relevant, so a tracing node is not required and everything can be indexed using events with the Safe L2 version.

Setup for production (tracing mode)

This is the recommended configuration for running a production Transaction service. docker-compose is required for running the project.

bash cp .env.tracing.sample .env

Configure the parameters needed on .env. These parameters need to be changed:

  • DJANGO_SECRET_KEY: Use a strong key.
  • ETHEREUM_NODE_URL: Http/s address of a ethereum node. It can be the same than ETHEREUM_TRACING_NODE_URL.
  • ETHEREUM_TRACING_NODE_URL: Http/s address of an OpenEthereum node with tracing enabled.

If you don't want to use trace_filter for the internal tx indexing and just rely on trace_block, set:

  • ETH_INTERNAL_NO_FILTER=1

For more parameters check base.py file.

Then:

docker-compose build --force-rm
docker-compose up

The service should be running in localhost:8000. You can test everything is set up:

curl 'http://localhost:8000/api/v1/about/'

You can go to http://localhost:5555/ to check the status of the task queue, also you can configure prometheus metrics.

For example, to set up a GΓΆerli node:

Run an OpenEthereum node in your local computer:

openethereum --chain goerli --tracing on --db-path=/media/ethereum/openethereum --unsafe-expose

Edit .env so docker points to the host OpenEthereum node:

ETHEREUM_NODE_URL=http://172.17.0.1:8545
ETHEREUM_TRACING_NODE_URL=http://172.17.0.1:8545

Then:

docker-compose build --force-rm
docker-compose up

Use admin interface

Services come with a basic administration web ui (provided by Django) by default on http://localhost:8000/admin/

A user must be created to get access:

docker exec -it safe-transaction-service-web-1 python manage.py createsuperuser

Safe Contract ABIs and addresses

Troubleshooting

Issues installing grpc on a Mac M1

If you face issues installing the grpc dependency locally (required by this project) on a M1 chip, set GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 and GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 and then try to install the dependency again.

FAQ

Why /v1/safes/{address} endpoint shows a nonce that indicates that a transaction was executed but the transaction is not shown or marked as executed in the other endpoints?

/v1/safes/{address} endpoint uses eth_call from the RPC to get the current information for a Safe, so there's no delay and as soon as a transaction is executed it will be updated. The other endpoints rely on polling, indexing decoding and processing of traces/events and take longer (shouldn't be more than half a minute).

How do you handle reorgs?

When indexed every block is marked as not confirmed unless it has some depth (configured via ETH_REORG_BLOCKS environment variable). Not confirmed blocks are checked periodically to check if the blockchain blockHash for that number changed before it reaches the desired number of confirmations, if that's the case, all blocks from that block and the transactions related are deleted and indexing is restarted to the last confirmed block.

If I add my chain to safe-eth-py will you support it?

No, for a chain to be supported we need to set up a dedicated infra for that network and have a proper RPC

How can I interact with service?

Aside from using standard HTTP requests:

What chains do you officially support?

https://docs.safe.global/learn/safe-core/safe-core-api/available-services

What means banned field in SafeContract model?

The banned field in the SafeContract model is used to prevent indexing of certain Safes that have an unsupported MasterCopy or unverified proxies that have issues during indexing. This field does not remove the banned Safe and indexing can be resumed once the issue has been resolved.

Contributors

See contributors

More Repositories

1

safe-smart-account

Safe allows secure management of blockchain assets.
TypeScript
1,827
star
2

safe-wallet-web

Safe{Wallet} – multisig EVM wallet
TypeScript
352
star
3

safe-apps-sdk

Client-side SDKs to create third-party Safe Apps
TypeScript
205
star
4

safe-core-sdk

The Safe{Core} Account Abstraction SDK allows builders to add account abstraction functionality into their apps.
TypeScript
202
star
5

safe-modules

A collection of modules that can be used with the Safe contract
TypeScript
140
star
6

safe-cli

Command line utility for Gnosis Safe
Python
138
star
7

safe-deployments

A collection of Safe singleton deployments
TypeScript
131
star
8

safe-eth-py

Safe-eth-py includes a set of libraries to work with Ethereum and relevant Ethereum projects
Python
118
star
9

safe-ios

Safe Multisig iOS app.
Swift
114
star
10

safe-react-apps

A repository for applications for Safe Web Interface
TypeScript
99
star
11

safe-android

πŸ” App to manage and interact with Safe
Kotlin
90
star
12

safe-singleton-factory

Singleton factory used by Safe related contracts
TypeScript
77
star
13

safe-docs

Developer Docs for building on Safe.
MDX
51
star
14

safe-react-components

Gnosis Safe component library
TypeScript
35
star
15

safe-user-allocation-reports

Python
34
star
16

account-abstraction-sdk

TypeScript
31
star
17

safe-config-service

The safe-config-service is a service that provides configuration information in the context of the Safe clients environment
Python
31
star
18

safe-client-gateway

Serves as a bridge for the Safe{Wallet} clients (Android, iOS, Web)
TypeScript
23
star
19

safe-gateway-typescript-sdk

Safe Gateway TypeScript SDK
TypeScript
20
star
20

safe-token

TypeScript
19
star
21

safe-infrastructure

One `docker-compose.yml` file to rule them all
Shell
19
star
22

safe-modules-deployments

This repo contains a collection of deployments of audited contracts from the Safe modules repository.
TypeScript
9
star
23

safe-ecosystem-database

Safe ecosystem database
HTML
6
star
24

safe-homepage

Safe homepage
TypeScript
6
star
25

safe-gelato-relay-service

The Safe Gelato Relay Service is a web service which allows relaying transactions via the Gelato Relay Service.
TypeScript
6
star
26

safe-services-status

πŸ“ˆ Uptime monitor and status page for Safe, powered by @upptime
Markdown
5
star
27

claiming-app-data

Vesting data converter and proofs generator.
Python
5
star
28

safe-dao-governance-app

The portal to Safe{DAO} governance, voting power delegation and allocation claiming.
TypeScript
3
star
29

safe-pm

Production coordination for the Safe team primarily focused on Problems that need to be solved
2
star
30

safe-locking

Safe Token Locking Contracts
TypeScript
2
star
31

safe-guardians-page

This page is dedicated to the Safe Guardians program, a program designed to reward active members of the Safe community, who use their powers to contribute positively to the ecosystem.
TypeScript
2
star
32

safecon-landing-page

Safe{Con} landing page
CSS
1
star
33

cla-signatures

CLA signatures repository
1
star
34

token-list

This repo contain the Safe default token list. This list contains tokens which appear by default in the Safe wallet interface and are not part of the imported default token lists.
Shell
1
star