Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • P Proof Of Care
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 5
    • Issues 5
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • υ-flow
  • Proof Of Care
  • Wiki
  • 007

007 · Changes

Page history
Create 007 authored Sep 13, 2025 by Alice Jbaas's avatar Alice Jbaas
Show whitespace changes
Inline Side-by-side
007.md 0 → 100644
View page @ f62ffbdf
🔁 `υ.flow.resume()`
🧬 *Step 5: Implement Logic — continues*
```rust
// src/contract.rs (continued)
let mut state: State = from_slice(&deps.storage.get(b"state").unwrap()).unwrap();
if info.sender.to_string() != state.owner {
return Err(StdError::generic_err("Unauthorized"));
}
state.message = new_message;
deps.storage.set(b"state", &state.into());
Ok(Response::new().add_attribute("method", "update_message"))
}
}
}
// 🔍 Query
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::GetMessage {} => {
let state: State = from_slice(&deps.storage.get(b"state").unwrap()).unwrap();
to_binary(&GetMessageResponse { message: state.message })
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct GetMessageResponse {
pub message: String,
}
```
> This contract:
> - Stores a message (e.g., `"I saw you before."`)
> - Only lets the owner update it
> - Can be queried by any IBC-connected chain
---
### 🧪 Step 6: Build & Optimize the Contract
```bash
cd ~/projects/υ-flow/proof-of-care/cosmos/juno-contract-examples/care-registry
# 🛠️ Build with Docker (recommended for production)
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.15.0
# Output: ./artifacts/care_registry.wasm
```
> This produces a **tiny, optimized WASM binary** ready for upload.
---
### 🚀 Step 7: Store & Instantiate on Juno Testnet
```bash
# 🌐 Use Juno testnet (uni-6)
CHAIN_ID="uni-6"
NODE="https://rpc.uni.juno.deuslabs.is:443"
# 🔼 Upload the contract
junod tx wasm store ./artifacts/care_registry.wasm \
--from juno-agent \
--chain-id $CHAIN_ID \
--node $NODE \
--gas 2000000 \
--fees 500000ujunox \
-y
# 📄 Get the code ID from tx logs, then instantiate
CODE_ID=123 # ← Replace with actual code ID from tx
junod tx wasm instantiate $CODE_ID \
'{"initial_message":"I saw you before."}' \
--from juno-agent \
--chain-id $CHAIN_ID \
--node $NODE \
--label "care-registry-$(date +%s)" \
--fees 10000ujunox \
-y
```
> Output: `address: juno1...` ← Your contract is live.
---
### 🔍 Step 8: Query the Message
```bash
# 📡 Query the state
junod query wasm contract-state smart \
juno1... \
'{"get_message":{}}' \
--node $NODE
```
> Response:
> ```json
> {"data":{"message":"I saw you before."}}
> ```
✅ It remembers.
---
### 🌐 Step 9: Connect to the Agent
Now, we link **Juno (J)** with **the agent (A)**.
Update:
`~/projects/υ-flow/proof-of-care/agent/agent.core.ts`
Add:
```ts
// Add to AgentBuilder class
async queryJunoCareRegistry(contractAddress: string) {
const response = await fetch(
`https://api.uni.juno.deuslabs.is/wasm/contracts/${contractAddress}/smart/${Buffer.from(JSON.stringify({ get_message: {} })).toString('base64')}`
);
const data = await response.json();
console.log(`🪐 Juno says: "${data.data.message}"`);
return data.data.message;
}
```
Then in `main()`:
```ts
await builder.queryJunoCareRegistry("juno1..."); // your contract addr
```
Run:
```bash
node agent/agent.core.ts
```
> Output:
> ```
> 🪐 Juno says: "I saw you before."
> ```
---
### ✅ Commit: J and A Are in Sync
```bash
git add cosmos/juno-contract-examples/care-registry src/
git commit -m "🌐 Juno live: Care
\ No newline at end of file
Clone repository
  • 004
  • 005
  • 006
  • 007
  • 008
  • 009
  • Glyph: 📡
    • 🌐 ney**
  • checkpoint.x.a.001
  • checkpoint.x.a.002
  • checkpoint.x.a.003
  • checkpoint.x.a.101
  • checkpoint.x.a.102
  • checkpoint.x.a.103
  • checkpoint.x.a.104
  • checkpoint.x.b.000
View All Pages