Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faucet #2

Open
4 tasks
melvincarvalho opened this issue May 1, 2021 · 1 comment
Open
4 tasks

faucet #2

melvincarvalho opened this issue May 1, 2021 · 1 comment

Comments

@melvincarvalho
Copy link
Contributor

melvincarvalho commented May 1, 2021

Create a small proof of concept faucet that people can use to get started with marking

Functional requirements

  • Deposit
  • Withdraw from faucet
  • Display faucet balance
  • Prevent one user draining the faucet
@melvincarvalho
Copy link
Contributor Author

Inspiration from an etleneum faucet:

function __init__ ()
  return {}
end

function fundfaucet ()
  -- don't need to do anything here, any money you send will just be added
  -- to the total contract funds.
end

function getmoney ()
  -- here we require the user to be authenticated.
  if not account.id then
    -- this terminates the call execution and
    -- invalidates anything that might have happened before.
    error('you must be authenticated')
  end

  -- we let the user specify how much he's going to take from the faucet
  local money_to_get = tonumber(call.payload.money_to_get_msats)
  if not money_to_get then
    money_to_get = 10000 -- default to 10 sat
  end
  if money_to_get > 100000 then
    money_to_get = 100000 -- the amount is limited to 100 sat
  end

  -- this sends the money to the account balance of the caller
  contract.send(account.id, money_to_get)
end

https://etleneum.com/#/contract/cy0lmb1ldks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant