Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielwpz/near2aurora
https://github.com/danielwpz/near2aurora
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielwpz/near2aurora
- Owner: danielwpz
- Created: 2022-11-16T07:32:18.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-07T16:10:44.000Z (almost 2 years ago)
- Last Synced: 2024-03-15T06:04:11.581Z (8 months ago)
- Language: Rust
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# near2aurora
Helper module to call AURORA smart contracts from NEAR.## API
```rust
fn call(
aurora_account_id: &AccountId,
contract_address: &String,
method: &Function,
arguments: &Vec,
value: Option,
gas: Option,
) -> Promise;
```## Example
This example shows how to call the `approve` method on ERC20 tokens.The method signature : `function approve(address spender, uint256 amount) external returns (bool)`
To do so, you need to first define the method via `ethabi` exported by `near2aurora`:
```rust
let approve = near2aurora::Function {
name: "approve".to_string(),
inputs: vec![
Param {
name: "spender".to_string(),
kind: near2aurora::ParamType::Address,
internal_type: None,
},
Param {
name: "amount".to_string(),
kind: near2aurora::ParamType::Uint(256),
internal_type: None,
},
],
outputs: vec![Param {
name: "result".into(),
kind: near2aurora::ParamType::Bool,
internal_type: None,
}],
constant: None,
state_mutability: near2aurora::StateMutability::NonPayable,
};
```Then prepare the call args:
```rust
let args = vec![
Token::Address("6105fa59830085aa0ce57dbf5063af2c1d766b6b".parse().unwrap()),
Token::Uint(10000000000.into()),
]
```And finally make the call:
```rust
near2aurora::call(
&AccountId::new_unchecked("aurora".into()),
&contract_address,
&approve,
&args,
None,
None
);
```