PageSourceSearch

http://www.modality.org/assets/js/68d7d493.dd10caf5.js

js modality.org collected 2026-10-08 05:19:37 UTC 6,117 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdocs_site=globalThis.webpackChunkdocs_site||[]).push([[1518],{28453(e,t,s){s.d(t,{R:()=>a,x:()=>r});var o=s(96540);const n={},i=o.createContext(n);function a(e){const t=o.useContext(i);return o.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function r(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:a(e.components),o.createElement(i.Provider,{value:t},e.children)}},55536(e,t,s){s.r(t),s.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>a,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"id":"tutorials/their-state","title":"Their State, in Yours","description":"Another contract has posted a price. Yours should carry that price as they","source":"@site/docs/tutorials/their-state.md","sourceDirName":"tutorials","slug":"/tutorials/their-state","permalink":"/docs/tutorials/their-state","draft":false,"unlisted":false,"editUrl":"https://github.com/modality-org/modality/tree/main/docs/docs/tutorials/their-state.md","tags":[],"version":"current","sidebarPosition":14,"frontMatter":{"sidebar_position":14,"title":"Their State, in Yours"},"sidebar":"docsSidebar","previous":{"title":"Someone Else\'s Word","permalink":"/docs/tutorials/oracle-escrow"},"next":{"title":"Commit, Then Show","permalink":"/docs/tutorials/commit-then-show"}}');var n=s(74848),i=s(28453);const a={sidebar_position:14,title:"Their State, in Yours"},r="Their State, in Yours",c={},d=[{value:"The idea",id:"the-idea",level:2}];function l(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.header,{children:(0,n.jsx)(t.h1,{id:"their-state-in-yours",children:"Their State, in Yours"})}),"\n",(0,n.jsx)(t.p,{children:"Another contract has posted a price. Yours should carry that price as they\ncommitted it. A repost copies one path from a\nsource commit into your log. Your rules still have to accept the commit\nthat contains it."}),"\n",(0,n.jsx)(t.p,{children:"Build a source and post the price. Alice signs, as in the earlier pages."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:"modal contract create --dir ./price-source\ncd price-source\nmodal checkout\nmodal set-named-id /parties/alice.id example/alice\nmodal add-rule --name authorized \\\n  'always([-signed_by(/parties/alice.id)] false)'\n"})}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-modality",children:"model 
1Contract {\n  part flow {\n    q0 --\x3e q1\n    q1 --\x3e q1: +signed_by(/parties/alice.id)\n  }\n}\n"})}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:'modal commit --all -m "Source"\nmodal commit --path /facts/price.text --value "10 units" --sign example/alice -m "Price"\nmodal status\n'})}),"\n",(0,n.jsx)(t.p,{children:"Copy the source contract id. It is the Modality spelling."}),"\n",(0,n.jsx)(t.p,{children:"The destination is Bob's contract. A repost is a commit, and this witness\nallows Bob's signature on any later step, including the import."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:"cd ..\nmodal contract create --dir ./price-dest\ncd price-dest\nmodal checkout\nmodal set-named-id /parties/bob.id example/bob\nmodal add-rule --name authorized 'always([-signed_by(/parties/bob.id)] false)'\n"})}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-modality",children:"model Contract {\n  part flow {\n    q0 --\x3e q1\n    q1 --\x3e q1: +signed_by(/parties/bob.id)\n  }\n}\n"})}),"\n",(0,n.jsx)(t.p,{children:"Commit the bootstrap."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:'modal commit --all -m "Dest"\nmodal repost <source contract id> /facts/missing.text --from-dir ../price-source\n'})}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-output",children:"Path '/facts/missing.text' not found in source contract <source contract id>\n"})}),"\n",(0,n.jsxs)(t.p,{children:["Nothing was staged. The source has ",(0,n.jsx)(t.code,{children:"/facts/price.text"}),". Repost that path.\n",(0,n.jsx)(t.code,{children:"--from-dir"})," reads a local log. Without it, ",(0,n.jsx)(t.code,{children:"repost"})," reads the hub saved as\n",(0,n.jsx)(t.code,{children:"origin"}),". A source commit that has not been sequenced is refused when the\ndestination is checking a remote source: the snapshot is of a commit the\nnetwork has ordered."]}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-bash",children:'modal repost <source contract id> /facts/price.text --from-dir ../price-source\nmodal commit --all --sign example/bob -m "Take their price"\nmodal checkout\ncat state/reposts/<source contract id>/facts/price.text\n'})}),"\n",(0,n.jsxs)(t.p,{children:["The file is ",(0,n.jsx)(t.code,{children:"10 units"}),". The commit records the source contract, the source\npath, and the source commit id beside the value. After it is accepted, the\ndestination path is ordinary state."]}),"\n",(0,n.jsx)(t.h2,{id:"the-idea",children:"The idea"}),"\n",(0,n.jsxs)(t.p,{children:["A repost is a copy of one path at one source commit. The value is theirs,\nfrom that commit. The method label is ",(0,n.jsx)(t.code,{children:"+REPOST"}),". A\nwitness that only allows ",(0,n.jsx)(t.code,{children:"+POST"})," has to allow ",(0,n.jsx)(t.code,{children:"+REPOST"})," too, or leave the\nstep unlabeled, before the import commits. The destination's rules still\nrun. See ",(0,n.jsx)(t.a,{href:"/docs/reference/commit-methods#repost",children:"REPOST"}),". On the testnet,\nthe source commit is one that has sequenced. ",(0,n.jsx)(t.a,{href:"contract-hub",children:"Contract Hub"}),"\nis the same copy between two people."]}),"\n",(0,n.jsxs)(t.p,{children:["Next: ",(0,n.jsx)(t.a,{href:"commit-then-show",children:"Commit, then show"}),"."]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(l,{...e})}):l(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.