Skip to content

xmtp/smart-contracts

Repository files navigation

XMTP Contracts

⚠️ Experimental: This software is in early development. Expect frequent changes and unresolved issues.

This repository contains all the smart contracts that underpin the XMTP decentralized network.

Contracts documentation can be found here.

Solidity

Usage

The project is built with the Foundry framework, and dependency management is handled using native git submodules.

Additionally, it uses slither for static analysis.

Prerequisites

Install foundry

Install slither

Install node

Install prettier

Optionally, install yarn or any other preferred JS package manager.

Initialize project

Initialize the project dependencies:

npm install  # if using node
yarn install # if using yarn

Initialize foundry:

forge update

Developer tools

The following can be run using npm, yarn and similar JS package managers.

# Forge scripts
build:          Builds the contracts.
test:           Tests the contracts.
clean:          Cleans the forge environment.
coverage:       Shows the test coverage.
gas-report:     Shows the gas costs.
doc:            Serves the project documentation at http://localhost:4000

# Static analysis
slither:        Runs slither static analysis.

# Linters
solhint:        Runs solhint.
solhint-fix:    Runs solhint in fix mode, potentially modifying files.
lint-staged:    Runs linters only on files that are staged in git.

# Formatters
prettier:       Runs prettier in write mode, potentially modifying files.
prettier-check: Runs prettier in check mode.

Forge scripts

The project includes deployer and upgrade scripts.

Current available configuration options:

PRIVATE_KEY=0x000000000000000000000000000000000000dEaD
XMTP_GROUP_MESSAGE_BROADCASTER_ADMIN_ADDRESS=0x000000000000000000000000000000000000dEaD
XMTP_IDENTITY_UPDATE_BROADCASTER_ADMIN_ADDRESS=0x000000000000000000000000000000000000dEaD
XMTP_NODE_REGISTRY_ADMIN_ADDRESS=0x000000000000000000000000000000000000dEaD
XMTP_RATES_MANAGER_ADMIN_ADDRESS=0x000000000000000000000000000000000000dEaD