> For the complete documentation index, see [llms.txt](https://docs.swttoken.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.swttoken.com/smart-contracts/smart-contract-methods.md).

# Smart Contract Methods

#### sendTransaction <a href="#sendtransaction" id="sendtransaction"></a>

Transfers funds from one wallet address to another, using a specified number of coins. Optional data can be sent to the receiver, as long as the data is formatted using Base58 formatting.

`protected final void sendTransaction(String from, String to, double amount, byte... userData)`

* “addressFrom” - address funds are sent from.
* “addressTo” - address that receives sent funds
* "amount" - number of transferred funds
* "userData" - data uploaded by the user

```java
public void sendTransactionExample() {

		return sendTransaction(“addressFrom”, “addressTo”, amount, userData);

	}
```

#### invokeExternalContract <a href="#invokeexternalcontract" id="invokeexternalcontract"></a>

Invokes a method from another smart contract:

`Object invokeExternalContract(String contractAddress, String method, Object params)`

* "ContractAddress" - is the smart contract address
* "Method" - is the method that needs to be invoked
* "Params" - are the smart contract parameters, passed as an object

{% code overflow="wrap" %}

```java
public void invokeSmartContractMethod()

{

 Object[] params = new Object[] { param1, param2 };

 String resultStr = (String) invokeExternalContract("77GfsQD7peXrxTsjyNVCJmpWWBJAYA9oKy9FGZHb5mJt", "myMethod", params);

}
```

{% endcode %}

* Specify smart contract address, example: `tokenKey`;
* Smart contract method, example: `myMethod`;
* Specify method parameters, example: `Object[] params = new Object[] {param1, param2}`;
* Object `invokeExternalContract(String contractAddress, String method, Object... params)`.

#### getSeed <a href="#getseed" id="getseed"></a>

Generates a random 8 bit number used for development of gambling or gaming dApps.

`byte[] getSeed()`

```java
public Long getSeedExample() {

		return ByteBuffer.wrap(getSeed()).getLong();

	}
```

#### getBalance <a href="#getbalance" id="getbalance"></a>

Returns the coin balance for a wallet address.

`BigDecimal getBalance(String addressBase58)`

* "addressBase58" - the wallet address, in Base58 format

```java
public BigDecimal getBalanceExample() {

		return getBalance(address);

	}
```

#### getBlockchainTimeMills <a href="#getblockchaintimemills" id="getblockchaintimemills"></a>

Requests network time in milliseconds

`long getBlockchainTimeMills()`

```java
long getBlockchainTimeMillsExample() {

        return getBlockchainTimeMills();

    }
```

#### payable <a href="#payable" id="payable"></a>

This event is invoked when a smart contract receives coins via the Smart Contract Method called "sendTransaction".

`String payable(BigDecimal amount, byte[] userData)`

This event is triggered within the Smart Contract AFTER the Smart Contract "sendTransaction" method has finalized.

If an exception occurs within this event code, then the "sendTransaction" method fails and no Credits (CS) is transferred and no transaction fees are charged.

```java
String payable(BigDecimal amount, byte[] userData)

{

 string receivedData = userData;

 ...

}
```
