Skip to main content

Transfers

A transfer is the act of sending an asset from one address to another.

To transfer an asset, ensure that the sending address contains some ETH (by using a faucet, for example). This is required because the network uses ETH to pay for transaction fees.

Once your address has ETH in it, call the transfer function as follows:

# Transfer 0.00001 Ether to the destination address.
t = a.transfer(0.00001, :eth, destination_address)

# Wait for the transfer to settle.
t.wait!

The wait! Function

Crypto transactions take varying amounts of time—anywhere from hundreds of milliseconds, to tens of minutes, depending on the blockchain network and wallet set-up. For example, transactions on Bitcoin can take upwards of 30 minutes, while transactions on Base take a second or two.

To simplify these timings, the SDK provides a wait! function on the transfer object, so that you are notified when the transaction settles on the blockchain. A common pattern would be to use another thread to do so, so that your main application doesn’t block.

require 'async'

# Transfer 0.00001 Ether to the destination address.
t = a.transfer(0.00001, :eth, destination_address)

# Asynchronously wait for the transfer transaction to complete.
Async do |task|
t.wait!

# Do something with your wallet here.
end

Querying Transfer status

It is possible to query a crypto transaction’s status. A common case is to check whether the transaction succeeded or failed after calling wait!.

SDK Documentation

Refer to the Transfer class SDK docs for a full list of supported methods.

Was this helpful?