Documentation ¶
Index ¶
Constants ¶
const ( MasaTokenABIPath = "node_modules/@masa-finance/masa-token/deployments/sepolia/MasaToken.json" MasaFaucetABIPath = "node_modules/@masa-finance/masa-contracts-oracle/artifacts/contracts/MasaFaucet.sol/MasaFaucet.json" ProtocolStakingABIPath = "node_modules/@masa-finance/masa-contracts-oracle/artifacts/contracts/ProtocolStaking.sol/ProtocolStaking.json" )
Variables ¶
var MasaTokenAddress common.Address
var ProtocolStakingContractAddress common.Address
Functions ¶
func GetABI ¶
GetABI parses the ABI from the given JSON file path. It returns the parsed ABI, or an error if reading or parsing fails.
func VerifyStakingEvent ¶
VerifyStakingEvent checks if the given user address has staked tokens by calling the stakes() view function on the ProtocolStaking contract. It connects to an Ethereum node, encodes the stakes call, calls the contract, unpacks the result, and returns true if the stakes amount is > 0.
Types ¶
type Client ¶
type Client struct { EthClient *ethclient.Client PrivateKey *ecdsa.PrivateKey }
func NewClient ¶
func NewClient(privateKey *ecdsa.PrivateKey) (*Client, error)
NewClient initializes a new Client instance with the provided private key. It loads the contract addresses, initializes an Ethereum client, and returns a Client instance.
func (*Client) Approve ¶
Approve approves the specified amount of MASA tokens for transfer from the caller's account to the ProtocolStakingContractAddress. It constructs an Ethereum transaction with the approve call, signs it, sends it to the network, waits for confirmation, and returns the transaction hash if successful.
func (*Client) Stake ¶
Stake stakes the given amount of tokens from the client's account. It retrieves the network ID, creates a transactor, binds the staking contract instance, sends the stake transaction, waits for it to be mined, and returns the transaction hash if successful. Returns any errors.
type ContractAddresses ¶
type ContractAddresses struct { Sepolia struct { MasaFaucet string `json:"MasaFaucet"` MasaToken string `json:"MasaToken"` ProtocolStaking string `json:"ProtocolStaking"` } `json:"sepolia"` }
func LoadContractAddresses ¶
func LoadContractAddresses() (*ContractAddresses, error)
LoadContractAddresses loads the contract addresses from the addresses.json file. It returns a ContractAddresses struct containing the loaded addresses.