Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/build/guides/transactions/create-account.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,12 @@ func check(err error) {
import java.io.IOException;
import java.net.URI;
import java.net.http.*;
import java.math.BigDecimal;
import java.time.Duration;
import java.util.Collections;

import org.stellar.sdk.*;
import org.stellar.sdk.operations.*;
import org.stellar.sdk.requests.sorobanrpc.*;
import org.stellar.sdk.xdr.*;

Expand Down Expand Up @@ -530,7 +532,7 @@ public final class main {
Transaction transaction = new TransactionBuilder(parentAccount, Network.TESTNET)
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(TransactionBuilder.TIMEOUT_INFINITE)
.addOperation(new CreateAccountOperation.Builder(child.getAccountId(), "5").build())
.addOperation(CreateAccountOperation.builder().destination(child.getAccountId()).startingBalance(new BigDecimal("5")).build())
.build();
transaction.sign(parent);

Expand All @@ -545,7 +547,7 @@ public final class main {
log("Balance for account %s", parent.getAccountId());
log("XLM: %d", nativeBalance);

AssetTypeCreditAlphaNum12 usdcAsset = Asset.createNonNative("USDC", TESTNET_USDC_ISSUER);
Asset usdcAsset = Asset.createNonNativeAsset("USDC", TESTNET_USDC_ISSUER);
long trustlineBalance = getTrustlineBalance(parent.getAccountId(), usdcAsset);
log("USDC trustline balance (raw): %d", trustlineBalance);
}
Expand Down
10 changes: 5 additions & 5 deletions docs/build/guides/transactions/invoke-contract-tx-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,16 @@ Please go to [the project homepage](https://github.com/lightsail-network/java-st
:::

```java
import org.stellar.sdk.AccountNotFoundException;
import org.stellar.sdk.InvokeHostFunctionOperation;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Network;
import org.stellar.sdk.PrepareTransactionException;
import org.stellar.sdk.SorobanServer;
import org.stellar.sdk.Transaction;
import org.stellar.sdk.TransactionBuilder;
import org.stellar.sdk.TransactionBuilderAccount;
import org.stellar.sdk.requests.sorobanrpc.SorobanRpcErrorResponse;
import org.stellar.sdk.exception.AccountNotFoundException;
import org.stellar.sdk.exception.PrepareTransactionException;
import org.stellar.sdk.exception.SorobanRpcException;
import org.stellar.sdk.operations.InvokeHostFunctionOperation;
import org.stellar.sdk.responses.sorobanrpc.GetTransactionResponse;
import org.stellar.sdk.responses.sorobanrpc.SendTransactionResponse;
import org.stellar.sdk.scval.Scv;
Expand All @@ -256,7 +256,7 @@ import java.io.IOException;
import java.util.List;

public class Example {
public static void main(String[] args) throws SorobanRpcErrorResponse, IOException, InterruptedException {
public static void main(String[] args) throws SorobanRpcException, IOException, InterruptedException {
// The source account will be used to sign and send the transaction.
KeyPair sourceKeypair = KeyPair.fromSecretSeed("SAAPYAPTTRZMCUZFPG3G66V4ZMHTK4TWA6NS7U4F7Z3IMUD52EK4DDEV");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,24 @@ print(result)

```java
import java.io.IOException;
import org.stellar.sdk.AccountNotFoundException;
import org.stellar.sdk.InvokeHostFunctionOperation;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Network;
import org.stellar.sdk.PrepareTransactionException;
import org.stellar.sdk.SorobanServer;
import org.stellar.sdk.Transaction;
import org.stellar.sdk.TransactionBuilder;
import org.stellar.sdk.TransactionBuilderAccount;
import org.stellar.sdk.requests.sorobanrpc.SorobanRpcErrorResponse;
import org.stellar.sdk.exception.AccountNotFoundException;
import org.stellar.sdk.exception.PrepareTransactionException;
import org.stellar.sdk.exception.SorobanRpcException;
import org.stellar.sdk.operations.InvokeHostFunctionOperation;
import org.stellar.sdk.responses.sorobanrpc.GetTransactionResponse;
import org.stellar.sdk.responses.sorobanrpc.SendTransactionResponse;
import org.stellar.sdk.scval.Scv;
import org.stellar.sdk.xdr.TransactionMeta;

public class SorobanExample {
public static void main(String[] args)
throws SorobanRpcErrorResponse, IOException, InterruptedException {
throws SorobanRpcException, IOException, InterruptedException {

// The source account will be used to sign and send the transaction.
KeyPair sourceKeypair =
Expand Down
9 changes: 6 additions & 3 deletions docs/tokens/control-asset-access.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ server
```java
import org.stellar.sdk.*;
import org.stellar.sdk.Network;
import org.stellar.sdk.operations.SetOptionsOperation;
import org.stellar.sdk.responses.AccountResponse;

Server server = new Server("https://horizon-testnet.stellar.org");
Expand All @@ -159,12 +160,14 @@ KeyPair issuingKeys = KeyPair
.fromSecretSeed("SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4");
AccountResponse sourceAccount = server.accounts().account(issuingKeys.getAccountId());

Transaction setAuthorization = new Transaction.Builder(sourceAccount, Network.TESTNET)
.addOperation(new SetOptionsOperation.Builder()
.setSetFlags(
Transaction setAuthorization = new TransactionBuilder(sourceAccount, Network.TESTNET)
.addOperation(SetOptionsOperation.builder()
.setFlags(
AccountFlag.AUTH_REQUIRED_FLAG.getValue() |
AccountFlag.AUTH_REVOCABLE_FLAG.getValue())
Comment thread
ElliotFriend marked this conversation as resolved.
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(300)
.build();
setAuthorization.sign(issuingKeys);
server.submitTransaction(setAuthorization);
Expand Down
58 changes: 33 additions & 25 deletions docs/tokens/how-to-issue-an-asset.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,15 @@ transaction = (
Server server = new Server("https://horizon-testnet.stellar.org");
AccountResponse distributorAccount = server.accounts().account(distributorKeypair.getAccountId());

Transaction transaction = new Transaction.Builder(distributorAccount, Network.TESTNET)
Transaction transaction = new TransactionBuilder(distributorAccount, Network.TESTNET)
.addOperation(
new ChangeTrustOperation.Builder(astroDollar, "1000")
.setSourceAccount(distributorKeypair.getAccountId())
ChangeTrustOperation.builder()
.asset(new ChangeTrustAsset(astroDollar))
.limit(new BigDecimal("1000"))
.sourceAccount(distributorKeypair.getAccountId())
.build()
)
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(100)
.build();
```
Expand Down Expand Up @@ -322,15 +325,13 @@ transaction = (
```java
// We're using TransactionBuilder(...) as a short-hand here
// to show that these operations can be "chained" together.
Transaction transaction = new Transaction.Builder(...)
.addOperation(new PaymentOperation.Builder(
distributorKeypair.getAccountId(),
astroDollar,
"1000"
)
.setSourceAccount(
issuerKeypair.getAccountId()
)
Transaction transaction = new TransactionBuilder(...)
.addOperation(PaymentOperation.builder()
.destination(distributorKeypair.getAccountId())
.asset(astroDollar)
.amount(new BigDecimal("1000"))
.sourceAccount(issuerKeypair.getAccountId())
.build())
```

```go
Expand Down Expand Up @@ -393,10 +394,11 @@ lock_account_transaction = (
```

```java
Transaction lockAccountTransaction = new Transaction.Builder(...)
.addOperation(new SetOptionsOperation.Builder()
.setMasterKeyWeight(0)
.setSourceAccount(issuerKeypair.getAccountId())
Transaction lockAccountTransaction = new TransactionBuilder(...)
.addOperation(SetOptionsOperation.builder()
.masterKeyWeight(0)
.sourceAccount(issuerKeypair.getAccountId())
.build()
)
```

Expand Down Expand Up @@ -460,11 +462,13 @@ transaction = (

```java
AccountResponse issuerAccount = server.accounts().account(issuerKeys.getAccountId());
Transaction transaction = new Transaction.Builder(...)
.addOperation(new SetTrustLineFlagsOperation.Builder(
distributorKeys.getAccountId(),
astroDollar
).setAuthorized(true).build())
Transaction transaction = new TransactionBuilder(...)
.addOperation(SetTrustlineFlagsOperation.builder()
.trustor(distributorKeys.getAccountId())
.asset(astroDollar)
.setFlags(EnumSet.of(TrustLineFlags.AUTHORIZED_FLAG))
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(100)
.build();
```
Expand Down Expand Up @@ -644,20 +648,24 @@ Asset astroDollar = Asset.createNonNativeAsset("AstroDollar", issuerKeys.getAcco

// First, the receiving account must trust the asset
AccountResponse receiving = server.accounts().account(receivingKeys.getAccountId());
Transaction allowAstroDollars = new Transaction.Builder(receiving, Network.TESTNET)
Transaction allowAstroDollars = new TransactionBuilder(receiving, Network.TESTNET)
.addOperation(
// The `ChangeTrust` operation creates (or alters) a trustline
// The second parameter limits the amount the account can hold
new ChangeTrustOperation.Builder(astroDollar, "1000").build())
ChangeTrustOperation.builder().asset(new ChangeTrustAsset(astroDollar)).limit(new BigDecimal("1000")).build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(180)
.build();
allowAstroDollars.sign(receivingKeys);
server.submitTransaction(allowAstroDollars);

// Second, the issuing account actually sends a payment using the asset
AccountResponse issuer = server.accounts().account(issuerKeys.getAccountId());
Transaction sendAstroDollars = new Transaction.Builder(issuer, Network.TESTNET)
Transaction sendAstroDollars = new TransactionBuilder(issuer, Network.TESTNET)
.addOperation(
new PaymentOperation.Builder(receivingKeys.getAccountId(), astroDollar, "10").build())
PaymentOperation.builder().destination(receivingKeys.getAccountId()).asset(astroDollar).amount(new BigDecimal("10")).build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(180)
.build();
sendAstroDollars.sign(issuerKeys);
server.submitTransaction(sendAstroDollars);
Expand Down
8 changes: 5 additions & 3 deletions docs/tokens/publishing-asset-info.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,11 @@ KeyPair issuingKeys = KeyPair
.fromSecretSeed("SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4");
AccountResponse sourceAccount = server.accounts().account(issuingKeys.getAccountId());

Transaction setHomeDomain = new Transaction.Builder(sourceAccount, Network.TESTNET)
.addOperation(new SetOptionsOperation.Builder()
.setHomeDomain("yourdomain.com").build())
Transaction setHomeDomain = new TransactionBuilder(sourceAccount, Network.TESTNET)
.addOperation(SetOptionsOperation.builder()
.homeDomain("yourdomain.com").build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(180)
.build();
setHomeDomain.sign(issuingKeys);
server.submitTransaction(setHomeDomain);
Expand Down
Loading