You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the tutorials on Solana Playground. The goal is to create a contract that will send others some tokens when requested.
I am following the tutorial exactly but I keep getting this error, I have tried changing stuff but no avail. init_faucet gives the error (its the only one I am trying to test right now)
----------------- Seahorse CODE ---------
from seahorse.prelude import *
from seahorse.pyth import *
assert mint.key() == faucet.mint, 'Faucet token does not match the token provided'
assert timestamp - 30 > faucet.last_withdraw, 'Please try again in 30 seconds'
btc_price_feed = bitcoin_price_account.validate_price_feed('devnet-BTC/USD')
btc_price = u64(btc_price_feed.get_price().price)
btc_price = btc_price // 100_000_000 # converts to dollar units i.e. 4313965499999 -> 43,139
Following the tutorials on Solana Playground. The goal is to create a contract that will send others some tokens when requested.
I am following the tutorial exactly but I keep getting this error, I have tried changing stuff but no avail. init_faucet gives the error (its the only one I am trying to test right now)
----------------- Seahorse CODE ---------
from seahorse.prelude import *
from seahorse.pyth import *
declare_id('4kNg32e3FurYQwK4nRH2cXruj2HZDkTWi9c8TL2c7jT5')
class BitcornFaucet(Account):
bump: u8
owner: Pubkey
mint: Pubkey
last_withdraw: i64 # timestamp
@Instruction
def init_faucet(
signer: Signer,
mint: TokenMint,
faucet: Empty[BitcornFaucet],
faucet_account: Empty[TokenAccount]):
bump = faucet.bump()
faucet = faucet.init(
payer = signer,
seeds = ['mint', mint]
)
faucet_account.init(
payer = signer,
seeds = ["token-seed", mint],
mint = mint,
authority = faucet,
)
faucet.bump = bump
faucet.mint = mint.key()
faucet.owner = signer.key()
drips tokens based on the oracle price of BTC
@Instruction
def drip_bitcorn_tokens(
signer: Signer,
mint: TokenMint,
faucet: BitcornFaucet,
faucet_account: TokenAccount,
user_account: TokenAccount,
bitcoin_price_account: PriceAccount,
clock: Clock):
timestamp: i64 = clock.unix_timestamp()
assert mint.key() == faucet.mint, 'Faucet token does not match the token provided'
assert timestamp - 30 > faucet.last_withdraw, 'Please try again in 30 seconds'
btc_price_feed = bitcoin_price_account.validate_price_feed('devnet-BTC/USD')
btc_price = u64(btc_price_feed.get_price().price)
btc_price = btc_price // 100_000_000 # converts to dollar units i.e. 4313965499999 -> 43,139
print("The Bitcorn price is ", btc_price)
thousand_bucks = 1000 * 1_000_000_000
drip_amount = u64(thousand_bucks // btc_price)
bump = faucet.bump
faucet_account.transfer(
authority = faucet,
to = user_account,
amount = u64(drip_amount),
signer = ['mint', mint, bump]
)
send tokens back to replenish the faucet
@Instruction
def replenish_bitcorn_tokens(
signer: Signer,
mint: TokenMint,
user_account: TokenAccount,
faucet_account:
TokenAccount,
amount: u64):
user_account.transfer(
authority = signer,
to = faucet_account,
amount = u64(amount)
)
-----------Inputs--------
signer : 6LC1rBqxjEUnTv1iUQ46pdjQH9hNuoJsbUq6jffMfFM6
mint : HAgxZX4DKW9u7ZbvG782zhScGLLZecNCv389pBAsNj4w (token I minted)
faucet : CatovpWXj4ce9QhSTD1VmmPKjyg1ysrgUBGNBg7nMBvc (random)
faucetAccount : 6VwuiXxMMuMs2Vzszct433v7e7R6NvXaAmwvpjTrFLzX (random)
rent : SysvarRent111111111111111111111111111111111
systemProgram : 11111111111111111111111111111111
tokenProgram : TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
The text was updated successfully, but these errors were encountered: