Documentation
¶
Overview ¶
Package txbuilder provides a fluent builder for native TRON transactions (transfers, staking, voting, etc.) with Build / Send / SendAndConfirm terminal operations.
Index ¶
- type Builder
- func (b *Builder) DelegateResource(from, to string, resource core.ResourceCode, amount int64, opts ...Option) *DelegateTx
- func (b *Builder) FreezeV2(from string, amount int64, resource core.ResourceCode, opts ...Option) *Tx
- func (b *Builder) Transfer(from, to string, amount int64, opts ...Option) *Tx
- func (b *Builder) UnDelegateResource(from, to string, resource core.ResourceCode, amount int64, opts ...Option) *Tx
- func (b *Builder) UnfreezeV2(from string, amount int64, resource core.ResourceCode, opts ...Option) *Tx
- func (b *Builder) VoteWitness(from string, opts ...Option) *VoteTx
- type Client
- type DelegateTx
- type Option
- type Receipt
- type Tx
- func (t *Tx) Build(ctx context.Context) (*api.TransactionExtention, error)
- func (t *Tx) Decode(ctx context.Context) (*transaction.ContractData, error)
- func (t *Tx) Send(ctx context.Context, s signer.Signer) (*Receipt, error)
- func (t *Tx) SendAndConfirm(ctx context.Context, s signer.Signer) (*Receipt, error)
- type VoteTx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is the entry point for constructing native TRON transactions. Create one with New, then call transaction methods (Transfer, FreezeV2, etc.) to get a Tx with terminal operations.
func New ¶
New creates a Builder bound to the given client. Options set shared defaults that apply to every transaction produced by this builder.
func (*Builder) DelegateResource ¶
func (b *Builder) DelegateResource(from, to string, resource core.ResourceCode, amount int64, opts ...Option) *DelegateTx
DelegateResource creates a resource delegation transaction. Use .Lock(period) on the returned DelegateTx to enable delegation locking.
func (*Builder) FreezeV2 ¶
func (b *Builder) FreezeV2(from string, amount int64, resource core.ResourceCode, opts ...Option) *Tx
FreezeV2 creates a Stake 2.0 freeze transaction.
func (*Builder) UnDelegateResource ¶
func (b *Builder) UnDelegateResource(from, to string, resource core.ResourceCode, amount int64, opts ...Option) *Tx
UnDelegateResource creates a resource un-delegation transaction.
func (*Builder) UnfreezeV2 ¶
func (b *Builder) UnfreezeV2(from string, amount int64, resource core.ResourceCode, opts ...Option) *Tx
UnfreezeV2 creates a Stake 2.0 unfreeze transaction.
type Client ¶
type Client interface {
TransferCtx(ctx context.Context, from, toAddress string, amount int64) (*api.TransactionExtention, error)
BroadcastCtx(ctx context.Context, tx *core.Transaction) (*api.Return, error)
GetTransactionInfoByIDCtx(ctx context.Context, id string) (*core.TransactionInfo, error)
FreezeBalanceV2Ctx(ctx context.Context, from string, resource core.ResourceCode, frozenBalance int64) (*api.TransactionExtention, error)
UnfreezeBalanceV2Ctx(ctx context.Context, from string, resource core.ResourceCode, unfreezeBalance int64) (*api.TransactionExtention, error)
DelegateResourceCtx(ctx context.Context, from, to string, resource core.ResourceCode, delegateBalance int64, lock bool, lockPeriod int64) (*api.TransactionExtention, error)
UnDelegateResourceCtx(ctx context.Context, owner, receiver string, resource core.ResourceCode, delegateBalance int64) (*api.TransactionExtention, error)
VoteWitnessAccountCtx(ctx context.Context, from string, witnessMap map[string]int64) (*api.TransactionExtention, error)
}
Client is the subset of GrpcClient that transaction builders need. Accepting an interface avoids import cycles and simplifies testing.
type DelegateTx ¶
type DelegateTx struct {
*Tx
// contains filtered or unexported fields
}
DelegateTx is a delegation transaction builder with a fluent Lock method. It embeds *Tx so all terminal operations (Build, Send, SendAndConfirm) are available directly.
func (*DelegateTx) Lock ¶
func (d *DelegateTx) Lock(period int64) *DelegateTx
Lock enables the delegation lock with the given period (in blocks). Returns itself for chaining.
type Option ¶
type Option func(*config)
Option configures a Tx.
func WithPermissionID ¶
WithPermissionID sets the permission ID used for multi-signature transactions.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a single prepared transaction with terminal operations.
func (*Tx) Build ¶
Build creates the unsigned transaction, applying any configured options (permission ID, memo, etc.).
func (*Tx) Decode ¶
func (t *Tx) Decode(ctx context.Context) (*transaction.ContractData, error)
Decode builds the transaction and decodes the first contract parameter into human-readable fields (base58 addresses, TRX-formatted amounts). Useful for inspecting or displaying what a transaction does before signing.
type VoteTx ¶
type VoteTx struct {
*Tx
// contains filtered or unexported fields
}
VoteTx is a vote transaction builder with fluent methods for adding votes. It embeds *Tx so all terminal operations (Build, Send, SendAndConfirm) are available directly.