> ## Documentation Index
> Fetch the complete documentation index at: https://docs.near.org/llms.txt
> Use this file to discover all available pages before exploring further.

# External Interface

> Learn how to define your contract's interface.

export const File = ({children}) => {
  return children;
};

export const Block = ({children}) => {
  return children;
};

export const ExplainCode = ({children, languages}) => {
  const langList = typeof languages === 'string' ? languages.split(',') : languages || [];
  const [language, setLanguage] = useState(langList[0]);
  const [activeBlock, setActiveBlock] = useState(0);
  const [code, setCode] = useState(null);
  const blockRefs = useRef({});
  const codeContainerRef = useRef(null);
  const ratioMap = useRef({});
  const lang2label = {
    rust: '🦀 Rust',
    js: '🌐 JS',
    ts: '🌐 TS',
    python: '🐍 Python',
    go: '🐹 Go'
  };
  const typeAccentClass = {
    state: 'border-l-4 border-emerald-500',
    warning: 'border-l-4 border-amber-500',
    note: 'border-l-4 border-amber-500'
  };
  const accentBorder = t => typeAccentClass[t] || 'border-l-4 border-indigo-500';
  function toRaw(ref) {
    const fullUrl = ref.slice(ref.indexOf('https'));
    const [url] = fullUrl.split('#');
    const [org, repo, , branch, ...pathSeg] = new URL(url).pathname.split('/').slice(1);
    return `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${pathSeg.join('/')}`;
  }
  async function fetchRaw(url, fromLine, toLine) {
    let res;
    if (typeof window !== 'undefined') {
      const validUntil = localStorage.getItem(`${url}-until`);
      if (validUntil && Number(validUntil) > Date.now()) {
        res = localStorage.getItem(url);
      }
    }
    if (!res) {
      try {
        res = await (await fetch(url)).text();
        if (typeof window !== 'undefined') {
          localStorage.setItem(url, res);
          localStorage.setItem(`${url}-until`, String(Date.now() + 60000));
        }
      } catch {
        return 'Error fetching code, please try reloading';
      }
    }
    let lines = res.split('\n');
    const from = fromLine ? Number(fromLine) - 1 : 0;
    const to = toLine ? Number(toLine) : lines.length;
    lines = lines.slice(from, to);
    const indent = lines.reduce((prev, line) => {
      if (!line.length) return prev;
      const m = line.match(/^\s+/);
      return m ? Math.min(prev, m[0].length) : 0;
    }, Infinity);
    return lines.map(l => l.slice(indent === Infinity ? 0 : indent)).join('\n');
  }
  function parseHighlights(str) {
    const set = new Set();
    if (!str) return set;
    String(str).split(',').forEach(part => {
      const [a, b] = part.trim().split('-');
      if (b) {
        for (let i = Number(a); i <= Number(b); i++) set.add(i);
      } else if (a) set.add(Number(a));
    });
    return set;
  }
  const childArray = Array.isArray(children) ? children.flat(Infinity) : children ? [children] : [];
  const blocks = [];
  const files = [];
  for (const child of childArray) {
    if (!child || typeof child !== 'object' || !child.props) continue;
    if (child.props.highlights !== undefined) {
      let hl = {};
      try {
        hl = JSON.parse(child.props.highlights);
      } catch {}
      if ((language in hl)) {
        blocks.push({
          text: child.props.children,
          highlight: hl[language],
          fname: child.props.fname,
          type: child.props.type
        });
      }
    } else if (child.props.language === language) {
      files.push({
        ...child.props
      });
    }
  }
  const activeFname = blocks[activeBlock]?.fname || files[0]?.fname;
  const fileKey = `${activeFname}-${language}`;
  const currentFile = files.find(f => f.fname === activeFname) || files[0];
  useEffect(() => {
    setActiveBlock(0);
    setCode(null);
    ratioMap.current = {};
  }, [language]);
  useEffect(() => {
    const observedEls = Object.entries(blockRefs.current).filter(([, el]) => el);
    const observer = new IntersectionObserver(entries => {
      entries.forEach(entry => {
        const idx = Number(entry.target.dataset.blockIdx);
        ratioMap.current[idx] = entry.intersectionRatio;
      });
      let bestIdx = -1;
      let bestRatio = 0;
      Object.entries(ratioMap.current).forEach(([idx, ratio]) => {
        if (ratio > bestRatio) {
          bestRatio = ratio;
          bestIdx = Number(idx);
        }
      });
      if (bestIdx !== -1) {
        setActiveBlock(bestIdx);
      } else {
        const zoneTop = window.innerHeight * 0.2;
        const allAboveZone = Object.entries(blockRefs.current).filter(([, el]) => el).every(([, el]) => el.getBoundingClientRect().bottom < zoneTop);
        if (allAboveZone) setActiveBlock(-1);
      }
    }, {
      threshold: [0, 0.1, 0.25, 0.5, 0.75, 1],
      rootMargin: '-20% 0px -50% 0px'
    });
    observedEls.forEach(([idx, el]) => {
      el.dataset.blockIdx = idx;
      observer.observe(el);
    });
    return () => observer.disconnect();
  }, [blocks.length]);
  useEffect(() => {
    const container = codeContainerRef.current;
    if (!container) return;
    const firstHL = container.querySelector('[data-first-hl]');
    if (!firstHL) return;
    const targetScrollTop = container.scrollTop + firstHL.getBoundingClientRect().top - container.getBoundingClientRect().top - container.clientHeight / 2 + firstHL.offsetHeight / 2;
    container.scrollTo({
      top: Math.max(0, targetScrollTop),
      behavior: 'smooth'
    });
  }, [activeBlock]);
  useEffect(() => {
    if (!currentFile?.url) return;
    setCode(null);
    const rawUrl = toRaw(currentFile.url);
    fetchRaw(rawUrl, currentFile.start, currentFile.end).then(setCode);
  }, [fileKey]);
  const startLine = currentFile?.start ? Number(currentFile.start) : 1;
  const highlighted = parseHighlights(blocks[activeBlock]?.highlight);
  const firstHlLine = highlighted.size > 0 ? Math.min(...highlighted) : -1;
  return <div className="my-6 not-prose">
      {}
      <div className="flex border-b border-gray-200 dark:border-gray-700 mb-4">
        {langList.map(lang => <button key={lang} onClick={() => setLanguage(lang)} className={['px-4 py-2 text-sm font-medium bg-transparent cursor-pointer', 'border-0 border-b-2 -mb-px transition-colors outline-none', language === lang ? 'border-blue-500 text-blue-500 dark:text-blue-400 dark:border-blue-400' : 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200'].join(' ')}>
            {lang2label[lang] || lang}
          </button>)}
      </div>

      {}
      <div className="flex gap-8 items-start">
        {}
        <div className="flex-[5] flex flex-col gap-3 min-w-0 pb-[40vh]">
          {blocks.map((block, i) => <div key={i} ref={el => {
    blockRefs.current[i] = el;
  }} onClick={() => !block.type && setActiveBlock(i)} className={['px-5 py-4 rounded-md transition-all duration-200', block.type ? `cursor-default ${accentBorder(block.type)} opacity-75` : activeBlock === i ? `cursor-pointer ${accentBorder(block.type)} shadow-sm` : `cursor-pointer ${accentBorder(block.type)} opacity-60 hover:opacity-90`].join(' ')} style={{
    backgroundColor: block.type ? 'var(--explain-card-bg)' : activeBlock === i ? 'var(--explain-card-active-bg)' : 'var(--explain-card-bg)',
    border: !block.type && activeBlock === i ? '1px solid var(--explain-card-border)' : '1px solid transparent'
  }}>
              {block.text}
            </div>)}
        </div>

        {}
        {currentFile && <div className="flex-[6] min-w-0 rounded-[10px] border border-[#d0d7de] dark:border-[#30363d] overflow-hidden sticky top-6 max-h-[calc(100vh-5rem)] flex flex-col shadow-md bg-white dark:bg-[#0d1117]">
            {}
            <div className="flex items-center justify-between px-[14px] py-2 bg-[#f6f8fa] dark:bg-[#161b22] border-b border-[#d0d7de] dark:border-[#30363d] shrink-0">
              <div className="flex items-center gap-2">
                <svg width="14" height="14" viewBox="0 0 24 24" className="fill-[#657279] dark:fill-[#8b949e]">
                  <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" />
                </svg>
                <span className="text-[0.8125rem] font-medium text-[#1f2328] dark:text-[#e6edf3]">{currentFile.fname}</span>
              </div>
              <a href={`${currentFile.url}#L${currentFile.start}-L${currentFile.end}`} target="_blank" rel="noreferrer noopener" className="text-[0.6875rem] no-underline flex items-center gap-1 transition-colors text-[#656d76] dark:text-[#8b949e] hover:text-[#1f2328] dark:hover:text-[#e6edf3]">
                View on GitHub
                <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
                  <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
                  <polyline points="15 3 21 3 21 9" />
                  <line x1="10" y1="14" x2="21" y2="3" />
                </svg>
              </a>
            </div>

            {}
            <div className="overflow-auto flex-1" ref={codeContainerRef}>
              {code === null ? <div className="p-4 text-xs text-gray-500 dark:text-gray-400">Loading...</div> : <table className="w-full border-collapse font-mono text-[13px] leading-relaxed">
                  <tbody>
                    {code.split('\n').map((line, i) => {
    const lineNum = startLine + i;
    const isHL = highlighted.has(i + 1);
    return <tr key={i} {...i + 1 === firstHlLine ? {
      'data-first-hl': ''
    } : {}} style={isHL ? {
      backgroundColor: 'rgba(250,204,21,0.08)'
    } : undefined}>
                          <td style={{
      minWidth: '70px'
    }} className="py-0 pl-3 pr-3 text-right text-[0.7rem] text-[#8c959f] dark:text-gray-400 w-12 min-w-[3rem] whitespace-nowrap border-r border-[#d0d7de] dark:border-gray-700 select-none align-top">
                            {lineNum}
                          </td>
                          <td style={isHL ? {
      borderLeft: '2px solid #facc15'
    } : undefined} className="pl-4 pr-6 whitespace-pre text-[#1f2328] dark:text-[#e6edf3] align-top">
                            {line || ' '}
                          </td>
                        </tr>;
  })}
                  </tbody>
                </table>}
            </div>
          </div>}
      </div>
    </div>;
};

Smart contracts expose functions so users can interact with them. There are different types of functions including `read-only`, `private` and `payable`.

<ExplainCode languages="rust,js,python,go">
  <Block highlights="{&#x22;js&#x22;: &#x22;16-20,23-42,45-50,53-55,58-60&#x22;, &#x22;rust&#x22;: &#x22;24-34,37-62,64-75,77-79,81-83&#x22;, &#x22;python&#x22;: &#x22;4-22,25-62,65-94,97-99,102-104,107-121&#x22;, &#x22;go&#x22;: &#x22;30-40,42-78,80-121&#x22;}" fname="auction">
    ### Contract's Interface

    All **public** functions in the contract are part of its **interface**. They can be called by anyone, and are the only way to interact with the contract.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;&#x22;}" fname="auction" type="details">
    <Accordion title="Exposing trait implementations">
      Functions can also be exposed through trait implementations. This can be useful if implementing a shared interface or standard for a contract. This code generation is handled very similarly to basic `pub` functions, but the `#[near]` macro only needs to be attached to the trait implementation, not the trait itself:

      ```rust theme={"theme":{"light":"github-light","dark":"github-dark"}}
      pub trait MyTrait {
          fn trait_method(&mut self);
      }

      #[near]
      impl MyTrait for MyContractStructure {
          fn trait_method(&mut self) {
              // .. method logic here
          }
      }
      ```
    </Accordion>
  </Block>

  <Block highlights="{&#x22;js&#x22;:&#x22;15-20&#x22;, &#x22;rust&#x22;: &#x22;22-34&#x22;, &#x22;python&#x22;: &#x22;4-22&#x22;, &#x22;go&#x22;: &#x22;30-40&#x22;}" fname="auction">
    ### Initialization Functions

    A contract can opt to have an initialization function. If present, this function must be called before any other to [initialize the contract](./storage).
  </Block>

  <Block highlights="{&#x22;js&#x22;: &#x22;15&#x22;}" fname="auction">
    #### `@initialize({ privateFunction: true })`

    The initialization function is marked with the `@initialize` decorator.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;22&#x22;}" fname="auction">
    #### `#[init]`

    The initialization function is marked with the `#[init]` macro.
  </Block>

  <Block highlights="{&#x22;python&#x22;: &#x22;3&#x22;}" fname="auction">
    #### `@init`

    The initialization function is marked with the `@init` decorator in Python.
  </Block>

  <Block highlights="{&#x22;go&#x22;: &#x22;30&#x22;}" fname="auction">
    #### `@contract:init`

    The initialization function is marked with the `@contract:init` comment directive in Go.
  </Block>

  <Block highlights="{&#x22;js&#x22;:&#x22;22-42,44-50&#x22;, &#x22;rust&#x22;: &#x22;37-62,64-75&#x22;, &#x22;python&#x22;: &#x22;25-62,65-94&#x22;, &#x22;go&#x22;: &#x22;42-78,80-101&#x22;}" fname="auction">
    ### State Changing Functions

    The functions that modify the [state](./storage) or perform [actions](./actions) need to be called by a user with a NEAR account, since a transaction is required to execute them.
  </Block>

  <Block highlights="{&#x22;js&#x22;: &#x22;22,44&#x22;}" fname="auction">
    #### `@call`

    State changing functions are marked with the `@call` decorator.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;37,64&#x22;}" fname="auction">
    #### `&mut self`

    State changing functions are those that take a **mutable** reference to `self` in Rust.
  </Block>

  <Block highlights="{&#x22;python&#x22;: &#x22;24,64&#x22;}" fname="auction">
    #### `@call`

    State changing functions are marked with the `@call` decorator in Python.
  </Block>

  <Block highlights="{&#x22;go&#x22;: &#x22;43,80&#x22;}" fname="auction">
    #### `@contract:mutating`

    State changing functions are marked with the `@contract:mutating` comment directive in Go.
  </Block>

  <Block highlights="{&#x22;js&#x22;: &#x22;25,28,29&#x22;, &#x22;rust&#x22;: &#x22;40,45,46&#x22;, &#x22;python&#x22;: &#x22;109&#x22;, &#x22;go&#x22;: &#x22;45,64&#x22;}" fname="auction" type="info">
    <Tip>
      The SDK provides [contextual information](./environment), such as which account is calling the function, or what time it is.
    </Tip>
  </Block>

  <Block highlights="{&#x22;js&#x22;:&#x22;52-55,57-60&#x22;, &#x22;rust&#x22;: &#x22;77-79,81-83&#x22;, &#x22;python&#x22;: &#x22;97-99,102-104,107-121&#x22;, &#x22;go&#x22;: &#x22;103-121&#x22;}" fname="auction">
    ### Read-Only Functions

    Contract's functions can be read-only, meaning they don't modify the state. Calling them is free for everyone, and does not require to have a NEAR account.
  </Block>

  <Block highlights="{&#x22;js&#x22;: &#x22;52,57&#x22;}" fname="auction">
    #### `@view`

    Read-only functions are marked with the `@view` decorator in TS/JS.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;77,81&#x22;}" fname="auction">
    #### `&self`

    Read-only functions are those that take an **immutable** reference to `self` in Rust.
  </Block>

  <Block highlights="{&#x22;python&#x22;: &#x22;96,101,106&#x22;}" fname="auction">
    #### `@view`

    Read-only functions are marked with the `@view` decorator in Python.
  </Block>

  <Block highlights="{&#x22;go&#x22;: &#x22;103,108,113,118&#x22;}" fname="auction">
    #### `@contract:view`

    Read-only functions are marked with the `@contract:view` comment directive in Go.
  </Block>

  <Block highlights="{&#x22;js&#x22;:&#x22;15&#x22;, &#x22;rust&#x22;: &#x22;23&#x22;, &#x22;python&#x22;: &#x22;2&#x22;}" fname="auction">
    ### Private Functions

    Many times you will want to have functions that **are exposed** as part of the contract's interface, but **should not be called directly** by users.

    Besides initialization functions, [callbacks from cross-contract calls](./crosscontract) should always be `private`.

    These functions are marked as `private` in the contract's code, and can only be called by the contract itself.
  </Block>

  <Block highlights="{&#x22;js&#x22;: &#x22;15&#x22;}" fname="auction">
    #### `decorator({privateFunction: true})`

    Private functions are marked by setting `privateFunction: true` in the `@call` or `@initialize` decorators.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;23&#x22;}" fname="auction">
    #### \[#private]

    Private functions are marked using the `#[private]` macro in Rust.
  </Block>

  <Block highlights="{&#x22;python&#x22;: &#x22;2&#x22;}" fname="auction">
    #### Private Functions in Python

    In Python, you can create callbacks by using the `@callback` decorator, which is designed specifically for handling cross-contract call results. For general private functions that should only be called by the contract, you can use validation inside the function to check that the caller is the contract itself.
  </Block>

  <Block highlights="{&#x22;js&#x22;:&#x22;22,28&#x22;, &#x22;rust&#x22;: &#x22;36,45&#x22;, &#x22;python&#x22;: &#x22;25&#x22;, &#x22;go&#x22;: &#x22;42-78&#x22;}" fname="auction">
    ### Payable Functions

    By default, functions will panic if the user attaches NEAR Tokens to the call. Functions that accept NEAR Tokens must be marked as `payable`.

    Within the function, the user will have access to the [attached deposit](./environment).
  </Block>

  <Block highlights="{&#x22;js&#x22;: &#x22;22,28&#x22;}" fname="auction">
    #### `@call({payableFunction: true})`

    Payable functions are marked by setting `payableFunction: true` in the `@call` decorator.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;36,45&#x22;}" fname="auction">
    #### \[#payable]

    Payable functions are marked using the `#[payable]` macro in Rust.
  </Block>

  <Block fname="auction">
    #### Handling payments in Python

    In Python, you need to check the deposit manually using the Context API. There isn't a specific decorator for payable functions, so you'll need to verify the deposit amount in your function code.
  </Block>

  <Block highlights="{&#x22;go&#x22;: &#x22;42&#x22;}" fname="auction">
    #### `@contract:payable`

    In Go, functions that accept attached NEAR tokens can be marked with the `@contract:payable` comment directive. You can optionally specify a minimum deposit requirement: `@contract:payable min_deposit=1NEAR`. This directive is compatible with `@contract:mutating` and `@contract:init`.
  </Block>

  <Block highlights="{&#x22;js&#x22;:&#x22;3-5&#x22;}" fname="example">
    ### Internal Functions

    All the functions we covered so far are part of the interface, meaning they can be called by an external actor.

    However, contracts can also have private internal functions - such as helper or utility functions - that are **not exposed** to the outside world.

    To create internal private methods in a JS contract, simply omit the `@view` and `@call` decorators.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;5-7&#x22;}" fname="example">
    ### Internal Functions

    All the functions we covered so far are part of the interface, meaning they can be called by an external actor.

    However, contracts can also have private internal functions - such as helper or utility functions - that are **not exposed** to the outside world.

    To create internal private methods in a Rust contract, do not declare them as public (`pub fn`).
  </Block>

  <Block highlights="{&#x22;python&#x22;: &#x22;2-5&#x22;}" fname="example">
    ### Internal Functions

    All the functions we covered so far are part of the interface, meaning they can be called by an external actor.

    However, contracts can also have private internal functions - such as helper or utility functions - that are **not exposed** to the outside world.

    To create internal private methods in a Python contract, simply define normal methods without the `@view`, `@call`, or `@init` decorators.
  </Block>

  <Block highlights="{&#x22;go&#x22;: &#x22;123-127&#x22;}" fname="example">
    ### Internal Functions

    All the functions we covered so far are part of the interface, meaning they can be called by an external actor.

    However, contracts can also have private internal functions - such as helper or utility functions - that are **not exposed** to the outside world.

    To create internal private methods in a Go contract, simply define regular methods without any `@contract:` comment directives.
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;5-7&#x22;}" fname="example" type="details">
    <Accordion title="Separate impl block">
      Another way of not exporting methods is by having a separate `impl Contract` section, that is not marked with `#[near]`.

      ```rust theme={"theme":{"light":"github-light","dark":"github-dark"}}
      #[near]
      impl Contract {
          pub fn increment(&mut self) {
              self.internal_increment();
          }
      }
      impl Contract {
          /// This methods is still not exported.
          pub fn internal_increment(&mut self) {
              self.counter += 1;
          }
      }
      ```
    </Accordion>
  </Block>

  <Block highlights="{&#x22;rust&#x22;: &#x22;9-11,13-15&#x22;, &#x22;python&#x22;: &#x22;12-15&#x22;}" fname="example">
    ### Pure Functions

    Pure functions are a special kind of function that do not require to access data from the state.

    They are useful to return hardcoded values on the contract.
  </Block>

  <File language="js" fname="auction" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-ts/01-basic-auction/src/contract.ts" start="2" end="61" />

  <File language="rust" fname="auction" url="https://github.com/near-examples/auctions-tutorial/blob/main/contract-rs/01-basic-auction/src/lib.rs" start="2" end="84" />

  <File language="python" fname="auction" url="https://github.com/r-near/near-py-examples/blob/main/auction.py" start="2" end="140" />

  <File language="go" fname="auction" url="https://github.com/Emir-Asanov/near-go-examples/blob/example-release-1/auction/main.go" start="1" end="127" />

  <CodeBlock language="js" fname="example">
    ```js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    @NearBindgen({})
    class Contract {
      helper_function(params... ){
        // this function cannot be called from the outside
      }

      @view({})
      interface_view(params...){
        // this function can be called from outside
      }

      @call({privateFunction: true}){
        // this function can be called from outside, but
        // only by the contract's account
      }
    }
    ```
  </CodeBlock>

  <CodeBlock language="rust" fname="example">
    ```rs theme={"theme":{"light":"github-light","dark":"github-dark"}}
    const SOME_VALUE: u64 = 8;

    #[near]
    impl MyContractStructure {
      fn internal_helper(&mut self, params... ){
        // this function cannot be called from the outside
      }

      pub fn public_log(/* Parameters here */) {
          near_sdk::log!("inside log message");
      }

      pub fn return_static_u64() -> u64 {
          SOME_VALUE
      }
    }
    ```
  </CodeBlock>

  <CodeBlock language="python" fname="example">
    ```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    class Contract:
        def helper_function(self, params...):
            # This function cannot be called from the outside
            # as it has no decorator
            pass

        @call
        def validate_owner(self):
            if Context.predecessor_account_id() != self.owner_id:
                raise Exception("Only the owner can call this method")

        @view
        def get_static_value(self):
            # This function returns a hardcoded value
            return 42
    ```
  </CodeBlock>

  <CodeBlock language="go" fname="example">
    ```go theme={"theme":{"light":"github-light","dark":"github-dark"}}
    package main

    const SOME_VALUE uint64 = 8

    // @contract:state
    type MyContract struct {
        Counter uint64 `json:"counter"`
    }

    // Internal helper — no @contract: directive, not exposed to the outside
    func (c *MyContract) doubleValue(n uint64) uint64 {
        return n * 2
    }

    // @contract:view
    func (c *MyContract) GetStaticValue() uint64 {
        return SOME_VALUE
    }

    // @contract:view
    func (c *MyContract) GetDoubledCounter() uint64 {
        return c.doubleValue(c.Counter)
    }
    ```
  </CodeBlock>
</ExplainCode>
