Skip to content

Commit

Permalink
docs: Update README for factory contract and cross-contract examples …
Browse files Browse the repository at this point in the history
…with the changes requested.
  • Loading branch information
MattCS2006 committed Sep 18, 2024
1 parent e21012e commit 7f96c35
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
10 changes: 6 additions & 4 deletions examples/cross-contract-calls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,26 @@ cargo near create-dev-account
- Build and deploy the high-level contract:

```bash
cargo near deploy --wasmFile path/to/high-level-contract.wasm --accountId your-account.testnet
cargo build --target wasm32-unknown-unknown --release
near dev-deploy --wasmFile path/to/high-level-contract.wasm
```

- Build and deploy the low-level contract:

```bash
cargo near deploy --wasmFile path/to/low-level-contract.wasm --accountId your-account.testnet
cargo build --target wasm32-unknown-unknown --release
near dev-deploy --wasmFile path/to/low-level-contract.wasm
```

3. Initiate a cross-contract call:

- Call the high-level contract to initiate a cross-contract call to the low-level contract:

```bash
near call your-high-level-contract-account.testnet call-function '{"args": "value"}' --accountId your-account.testnet
near call your-high-level-contract-account.testnet calculate_factorial '{"number": 5}' --accountId your-account.testnet
```

NOTE: Replace `path/to/high-level-contract.wasm` and `path/to/low-level-contract.wasm` with the actual paths to your compiled WebAssembly files, and `your-account.testnet` with your actual NEAR testnet account ID.
NOTE: Replace path/to/high-level-contract.wasm and path/to/low-level-contract.wasm with the actual paths to your compiled WebAssembly files, and your-high-level-contract-account.testnet and your-account.testnet with your actual NEAR testnet account IDs.

## Dependencies

Expand Down
21 changes: 18 additions & 3 deletions examples/factory-contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,31 @@ cargo near create-dev-account
3. Deploy the factory contract:

```bash
cargo near deploy --wasmFile path/to/factory-contract.wasm --accountId your-account.testnet
cargo cargo build --target wasm32-unknown-unknown --release
near dev-deploy --wasmFile target/wasm32-unknown-unknown/release/factory_contract.wasm
```

4. Use the factory contract to create instances of the target contract:

```bash
near call your-factory-contract-account.testnet create_instance '{"args": "value"}' --accountId your-account.testnet
near contract call-function as-transaction your-factory-contract-account.testnet deploy_status_message json-args '{"account_id": "sub.your-factory-contract-account.testnet"}' prepaid-gas '100 Tgas' attached-deposit '0 NEAR'
```

NOTE: Replace `path/to/factory-contract.wasm` with the actual path to your compiled WebAssembly file, and `your-account.testnet` with your actual NEAR testnet account ID.
5. Demonstrate calls to simple_call and complex_call functions:

- Call simple_call function:

```bash
near call your-factory-contract-account.testnet simple_call '{"arg1": "value1"}' --accountId your-account.testnet
```

- Call complex_call function:

```bash
near call your-factory-contract-account.testnet complex_call '{"arg1": "value1", "arg2": "value2"}' --accountId your-account.testnet
```

NOTE FOR 3, 4 AND 5: Replace target/wasm32-unknown-unknown/release/factory_contract.wasm with the actual path to your compiled WebAssembly file, and your-factory-contract-account.testnet with your actual NEAR testnet account ID.

## Dependencies

Expand Down

0 comments on commit 7f96c35

Please sign in to comment.