Skip to main content
added 36 characters in body; edited tags
Source Link

When you send a raw instruction to the network, you have to specify in the instruction data an instruction identifier, so that the program knows what function to call. For example, in python:

from solana.rpc.api import Client
from solana.transaction import Transaction, TransactionInstruction

client = Client("http://localhost:8899")

prog_id = PublicKey("EcFTD...Js3fd")

txn = Transaction().add(
    TransactionInstruction([
        # accounts
        ...
    ],
    # program address
    prog_id,
    # data
    # instruction offset
    bytes(b"\xac\x89\xb7\x0e\xcfn\xea8")
    )
)

client.send_transaction(txn, sender)

that string, b"\xac\x89\xb7\x0e\xcfn\xea8", I found using some anchor when I started building the program. Now I have multiple functions, and can't figure out what data anchor expects me to pass to call the other ones.

When you send a raw instruction to the network, you have to specify in the instruction data an instruction identifier, so that the program knows what function to call. For example, in python:

from solana.rpc.api import Client
from solana.transaction import Transaction, TransactionInstruction

client = Client("http://localhost:8899")

prog_id = PublicKey("EcFTD...Js3fd")

txn = Transaction().add(
    TransactionInstruction([
        # accounts
        ...
    ],
    # program address
    prog_id,
    # data
    # instruction offset
    bytes(b"\xac\x89\xb7\x0e\xcfn\xea8")
    )
)

client.send_transaction(txn, sender)

that string, b"\xac\x89\xb7\x0e\xcfn\xea8", I found when I started building the program. Now I have multiple functions, and can't figure out what data to pass to call the other ones.

When you send a raw instruction to the network, you have to specify in the instruction data an instruction identifier, so that the program knows what function to call. For example, in python:

from solana.rpc.api import Client
from solana.transaction import Transaction, TransactionInstruction

client = Client("http://localhost:8899")

prog_id = PublicKey("EcFTD...Js3fd")

txn = Transaction().add(
    TransactionInstruction([
        # accounts
        ...
    ],
    # program address
    prog_id,
    # data
    # instruction offset
    bytes(b"\xac\x89\xb7\x0e\xcfn\xea8")
    )
)

client.send_transaction(txn, sender)

that string, b"\xac\x89\xb7\x0e\xcfn\xea8", I found using some anchor when I started building the program. Now I have multiple functions, and can't figure out what data anchor expects me to pass to call the other ones.

Source Link

Finding instruction identifiers

When you send a raw instruction to the network, you have to specify in the instruction data an instruction identifier, so that the program knows what function to call. For example, in python:

from solana.rpc.api import Client
from solana.transaction import Transaction, TransactionInstruction

client = Client("http://localhost:8899")

prog_id = PublicKey("EcFTD...Js3fd")

txn = Transaction().add(
    TransactionInstruction([
        # accounts
        ...
    ],
    # program address
    prog_id,
    # data
    # instruction offset
    bytes(b"\xac\x89\xb7\x0e\xcfn\xea8")
    )
)

client.send_transaction(txn, sender)

that string, b"\xac\x89\xb7\x0e\xcfn\xea8", I found when I started building the program. Now I have multiple functions, and can't figure out what data to pass to call the other ones.