Documentation
¶
Index ¶
- func ParseCompiledContract(path string) (*cell.Cell, error)
- func ParseCompiledTactContractFromFileBytes(data []byte) (*cell.Cell, error)
- func ParseCompiledTolkContractFromFileBytes(data []byte) (*cell.Cell, error)
- func Uint32From(res *ton.ExecutionResult, err error) (uint32, error)
- func Uint64From(res *ton.ExecutionResult, err error) (uint64, error)
- type Contract
- func (c *Contract) CallWait(message any, amount tlb.Coins) (*tracetracking.ReceivedMessage, error)
- func (c *Contract) CallWaitRecursively(message any, amount tlb.Coins) (*tracetracking.ReceivedMessage, error)
- func (c *Contract) Get(key string, params ...interface{}) (*ton.ExecutionResult, error)
- func (c *Contract) SendMessageWait(body *cell.Cell, amount tlb.Coins) (*tracetracking.ReceivedMessage, error)
- func (c *Contract) SubscribeToMessages(ctx context.Context, lt uint64) chan *tracetracking.ReceivedMessage
- type LazyLoadingContract
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Uint32From ¶
func Uint32From(res *ton.ExecutionResult, err error) (uint32, error)
func Uint64From ¶
func Uint64From(res *ton.ExecutionResult, err error) (uint64, error)
Types ¶
type Contract ¶
type Contract struct {
Address *address.Address
Client *tracetracking.SignedAPIClient
}
func Deploy ¶
func Deploy(ctx context.Context, client *tracetracking.SignedAPIClient, codeCell *cell.Cell, initData *cell.Cell, amount tlb.Coins, msgBody *cell.Cell) (*Contract, *tracetracking.ReceivedMessage, error)
Deploy deploys a contract to the blockchain. It takes the code cell of a compiled contract, the initial data for the contract, and the amount of TON to be sent to the contract upon deployment. It returns the contract wrapper if the deployment is successful. The function does not check the exit code of the deployment transaction as the exit code depends on the contract implementation. This is left to the caller. Example:
```
msg, err := tlb.ToCell(jetton_wrappers.TopUpMessage{QueryID: rand.Uint64()})
require.NoError(t, err, "failed to create top-up message")
receiverJettonWallet, deployMsg, err := wrappers.Deploy(&setup.common.receiver, jettonWalletCode, jettonWalletInitCell, tlb.MustFromTON("0.1"), //msg) require.NoError(t, err, "failed to deploy JettonWallet contract")
deployExitCode, err := deployMsg.OutgoingInternalReceivedMessages[0].ExitCode()
require.NoError(t, err, "failed to get deploy exit code") require.Zero(t, deployExitCode, "contract deployment failed: exit code %d: %s", deployExitCode, deployExitCode.Describe())
```
func Open ¶
func Open(client *tracetracking.SignedAPIClient, codeCell *cell.Cell, initData *cell.Cell) (*Contract, error)
func (*Contract) CallWait ¶
func (c *Contract) CallWait(message any, amount tlb.Coins) (*tracetracking.ReceivedMessage, error)
Calls a writer message on the contract and waits for it to be received. It does not wait for all the trace to be received, only the first message. Use CallWaitRecursively to wait for all the trace to be received. Message must implement github.com/xssnick/tonutils-go/tlb.Marshaller or provide tlb tags
func (*Contract) CallWaitRecursively ¶
func (c *Contract) CallWaitRecursively(message any, amount tlb.Coins) (*tracetracking.ReceivedMessage, error)
Calls a writer message on the contract and waits for it to be received. It waits for all the trace (outgoing messages) to be received. Use CallWait to wait only for this first message.
func (*Contract) Get ¶
func (c *Contract) Get(key string, params ...interface{}) (*ton.ExecutionResult, error)
Calls a getter method on the contract and waits for it to be received.
func (*Contract) SendMessageWait ¶
func (c *Contract) SendMessageWait(body *cell.Cell, amount tlb.Coins) (*tracetracking.ReceivedMessage, error)
Calls a writer message on the contract and waits for it to be received.
func (*Contract) SubscribeToMessages ¶
func (c *Contract) SubscribeToMessages(ctx context.Context, lt uint64) chan *tracetracking.ReceivedMessage
SubscribeToMessages returns a channel with all incoming messages for the given address that came after lt (Lamport Time). It will work retroactively, meaning that it will return all messages that are already in the blockchain and all new ones.
The caller must cancel the provided context when done reading from the channel to stop the subscription and prevent goroutine leaks.
type LazyLoadingContract ¶
func LazyLoadingTactContractInitData ¶
func LazyLoadingTactContractInitData[T any](contract T) LazyLoadingContract[T]
Wraps a contract with a lazy loading bit. This is useful for Tact contracts that require a lazy loading bit to be set to false.