Lets discuss which types smart contracts use to input and output data, as well as how such data is stored and handled in the contract’s code.
### Native Types
Smart contracts can receive, store and return data using JS native types:
– `string`
– `number`
– `boolean`
– `Array`
– `Map`
– `Object`
– `BigInt`
### Native Types
Smart contracts can receive, store and return data using the following Rust types:
– `string`
– `i8-i32/u8-u32`
– **`u64/128`**: It is preferable to use SDK types `U64` and `U128`
– `bool`
– `HashMap`
– `Vector`
`U64/U128`
Smart contracts can store `u64` and `u128`, but these types need to be converted to `string` for input/output, since JSON cannot serialize values with more than 52 bits
To simplify development, the SDK provides the `U64` and `U128` types which are automatically casted to `u64/u128` when stored, and to `string` when used as input/output
### Complex Objects
Smart contracts can store and return complex objects
**Note:** Objects will always be received and returned as JSON
#### Serializers
Objects that will be used as input or output need to be serializable to JSON, add the `#[near(serializer=json)]` macro
Objects that will be stored in the contract’s state need to be serializable to Borsh, add the `#[near(serializer=borsh)]` macro
### Handling Tokens
`$NEAR` tokens are typed as `BigInt` in JS, and their values represented in `yoctonear`
**Note:** 1 NEAR = 10^24 yoctoNEAR
### Handling Tokens
`$NEAR` tokens are handled through the `NearToken` struct, which exposes methods to represent the value in `yoctonear`, `milinear` and `near`
**Note:** 1 NEAR = 10^24 yoctonear
### Account
The SDK exposes a special type to handle NEAR Accounts, which automatically checks if the account address is valid