forked from ameliatastic/seahorse-lang
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathhello.py
43 lines (32 loc) · 806 Bytes
/
hello.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# hello
# Built with Seahorse v0.2.3
#
# Greets users to Solana by printing a message and minting them a token!
from seahorse.prelude import *
declare_id('Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS')
class Hello(Account):
bump: u8
@instruction
def init(owner: Signer, hello: Empty[Hello], mint: Empty[TokenMint]):
bump = hello.bump()
hello = hello.init(
payer=owner,
seeds=['hello']
)
mint.init(
payer = owner,
seeds = ['hello-mint'],
decimals = 0,
authority = hello
)
hello.bump = bump
@instruction
def say_hello(user_acc: TokenAccount, hello: Hello, mint: TokenMint):
bump = hello.bump
print(f'Hello {user_acc.authority()}, have a token!')
mint.mint(
authority = hello,
to = user_acc,
amount = u64(1),
signer = ['hello', bump]
)