> For the complete documentation index, see [llms.txt](https://fusee.gitbook.io/mx-sdk-as/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fusee.gitbook.io/mx-sdk-as/the-flip-smart-contract/the-flip-smart-contract-part-5-contract-administration.md).

# The Flip Smart Contract part 5 : Contract administration

## Modifying settings the storage

Three storages properties should be changed only by us :&#x20;

* maximum\_bet
* maximum\_bet\_percent
* minimum\_block\_bounty

For each of them we create an `@onlyOwner` endpoint :&#x20;

```typescript
@contract
abstract class FlipContract extends ContractBase {

    @onlyOwner
    setMaximumBet(
        tokenIdentifier: TokenIdentifier,
        nonce: ManagedU64,
        amount: BigUint
    ): void {
        this.require(
            amount > BigUint.zero(),
            "amount zero"
        )

        this.maximumBet(tokenIdentifier, nonce).set(amount)
    }

    @onlyOwner
    setMaximumBetPercent(
        tokenIdentifier: TokenIdentifier,
        nonce: ManagedU64,
        percent: ManagedU64
    ): void {
        this.require(
            percent > ManagedU64.zero(),
            "percent zero"
        )

        this.maximumBetPercent(tokenIdentifier, nonce).set(percent)
    }

    @onlyOwner
    setMinimumBlockBounty(
        minimumBlockBounty: ManagedU64
    ): void {
        this.require(
            minimumBlockBounty > ManagedU64.zero(),
            "minimum block bounty zero"
        )

        this.minimumBlockBounty().set(minimumBlockBounty)
    }
    
    //--- previous code ---
}
```

The `@onlyOwner` annotation ensure that only contract owner can call an endpoint. This is critical and should not be forgot.

{% hint style="warning" %}
Instead of TypeScript, you should always specify return type in AssemblyScript... even when it's `void` !
{% endhint %}

## Admin actions

Beside changing settings, the contract's owner need to do the two following actions :&#x20;

* increasing the contract's reserve of a token by sending token
* withdrawing token reserve

Let's code these two endpoints :&#x20;

```typescript
@contract
abstract class FlipContract extends ContractBase {

    @onlyOwner
    increaseReserve(): void {
        const payment = this.callValue.singlePayment

        this.require(
            payment.amount > BigUint.zero(),
            "no payment"
        )

        const oldTokenReserve = this.tokenReserve(payment.tokenIdentifier, payment.tokenNonce).get()

        this.tokenReserve(payment.tokenIdentifier, payment.tokenNonce).set(oldTokenReserve + payment.amount)
    }

    @onlyOwner
    withdrawReserve(
        tokenIdentifier: TokenIdentifier,
        nonce: ManagedU64,
        amount: BigUint
    ): void {
        const owner = this.blockchain.caller

        const tokenReserve = this.tokenReserve(tokenIdentifier, nonce).get()

        this.require(
            tokenReserve <= amount,
            "amount too high"
        )
        
        this.tokenReserve(tokenIdentifier, nonce).set(tokenReserve - amount)
        
        this.send.direct(
            owner,
            tokenIdentifier,
            nonce,
            amount
        )
    }
}
```

Nothing new here, this is similar to previous `onlyOwner` endpoints.

## Next up

Owner can now administrate the contract, next thing to code is the bet logic 🎲


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fusee.gitbook.io/mx-sdk-as/the-flip-smart-contract/the-flip-smart-contract-part-5-contract-administration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
