Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Exercise Four - Understanding the post posting code hook

Satinder Rawal answered on April 23, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Pre_Posting_Code Hook
  • post_posting_hook
  • ● Pre-Posting Code Hook

  • Exercise Four - Understanding the post posting code hook

    0

    Background

    Hooks have access to a set of hook directives, allowing them to affect the state of Vault. Some hooks, such as the pre posting code hook, are considered on the "hot path" and are not able to trigger hook directives.

    The post posting code hook allows us to check business logic after a posting's execution. In this exercise, we will add a check to the post posting hook to charge a customer a fee if they go over their overdraft limit.

    Exercise

    Using the predefined parameters overdraft_limit and overdraft_fee, implement logic that will fetch the balance of the account, check if the COMMITTED balance is greater than the allowed overdraft and charge a fee if it is.

    When fetching balances, you will need to use the DEFAULT_ADDRESS.

    To charge a fee, you use postings - postings. Postings represent the source of truth of the lowest level movement of funds inside of a bank. The Smart Contracts API has a helper function for instructing the movement of funds inside of Vault.

    The fee should be sent to the bank's internal account, stored in the variable internal_account.

    Add the following to the list of parameters:

    Popularity 1/10 Helpfulness 1/10 Language python
    Source: Grepper
    Tags: hook post python
    Link to this answer
    Share Copy Link
    Contributed on Apr 23 2023
    Satinder Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.