Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions contracts/contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,15 @@ cargo test -p contrib

All tests live in [`src/tests/`](src/tests/); nothing outside it is compiled
into test builds.

## Deployment

Deployment and initialization of `contrib` is handled via the unified workspace script:

```sh
cd contracts
./scripts/deploy.sh --network testnet --source alice
```

See [`contracts/scripts/README.md`](../scripts/README.md) for full usage and configuration details.

16 changes: 0 additions & 16 deletions contracts/contrib/scripts/.env.example

This file was deleted.

104 changes: 6 additions & 98 deletions contracts/contrib/scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,104 +1,12 @@
# Contrib Contract — Deploy & Initialize on Stellar Testnet
# Contrib Contract Deployment

## Prerequisites
Deployment and initialization of the `contrib` contract is consolidated into the canonical workspace deployment script.

| Tool | Version | Install |
|------|---------|---------|
| Rust | stable | `rustup default stable` |
| wasm32 target | — | `rustup target add wasm32-unknown-unknown` |
| stellar CLI | >= 22 | `cargo install stellar-cli` |
| curl | any | system package |

## Environment Setup

```bash
cd contracts/contrib/scripts

# 1. Create your .env from the example
cp .env.example .env

# 2. Fill in your admin secret key
# Generate a new keypair with: stellar keys generate
# Or use an existing one.
$EDITOR .env
```

The `.env` file requires three variables:

| Variable | Description | Example |
|----------|-------------|---------|
| `ADMIN_SECRET` | Ed25519 secret key (starts with `S`) | `SBUV...` |
| `NETWORK_PASSPHRASE` | Stellar network identifier | `Test SDF Network ; September 2015` |
| `RPC_URL` | Soroban RPC endpoint | `https://soroban-testnet.stellar.org:443` |

## Deploy Workflow

Run the three scripts in order:

### Step 1 — Fund the admin account

```bash
./setup-testnet.sh
```

This calls [Friendbot](https://developers.stellar.org/docs/learn/fund-and-create-an-account#testnet) to credit 10,000 XLM to the admin account on Testnet. Safe to re-run (idempotent).

### Step 2 — Compile & deploy the contract

```bash
./deploy.sh
```

What it does:

1. Compiles `contrib` to WASM via `cargo build --target wasm32-unknown-unknown --release`
2. Uploads the WASM and creates the contract instance via `stellar contract deploy`
3. Logs the **contract ID** to stdout
4. Persists the contract ID in `.env` as `CONTRACT_ID=...`

### Step 3 — Initialize the contract

```bash
./initialize.sh
```

What it does:

1. Derives the admin public address from `ADMIN_SECRET`
2. Calls `initialize(admin)` on the deployed contract via `stellar contract invoke`
3. The contract sets the admin, marks the contract as unpaused, sets total count to 0, and authorizes the admin as a registrar

### Verify
Please refer to [`contracts/scripts/README.md`](../../scripts/README.md) for the single documented workflow:

```bash
# Check the stored admin
stellar contract invoke \
--id "$CONTRACT_ID" \
--source-key "$ADMIN_SECRET" \
--network-passphrase "$NETWORK_PASSPHRASE" \
--rpc-url "$RPC_URL" \
-- get_admin

# Should print the admin's public address (G...)
cd contracts
./scripts/deploy.sh --network testnet --source alice
```

## Redeploying

To deploy a new instance after code changes:

```bash
./deploy.sh # builds, deploys, saves new CONTRACT_ID to .env
./initialize.sh # initializes the new instance
```

> **Note:** `deploy.sh` always creates a **new** contract instance. The old contract ID remains on-chain but is no longer referenced in your `.env`.

## Troubleshooting

| Problem | Fix |
|---------|-----|
| `error: no such target: wasm32-unknown-unknown` | `rustup target add wasm32-unknown-unknown` |
| `stellar: command not found` | `cargo install stellar-cli` |
| `RESOURCE_EXHAUSTED` on deploy | Contract WASM too large; enable `opt-level = "z"` in `Cargo.toml` (already set) |
| `Already initialized` on invoke | Contract was already initialized. Deploy a new instance. |
| `Insufficient balance` | Run `./setup-testnet.sh` again or wait for Friendbot rate limit to reset. |
This single command handles building, optimizing, deploying, and cross-contract initialization for `contrib` and the other contracts in the AssetsUp suite.
97 changes: 0 additions & 97 deletions contracts/contrib/scripts/deploy.sh

This file was deleted.

68 changes: 0 additions & 68 deletions contracts/contrib/scripts/initialize.sh

This file was deleted.

69 changes: 0 additions & 69 deletions contracts/contrib/scripts/setup-testnet.sh

This file was deleted.