Skip to content

Instantly share code, notes, and snippets.

@satran004
satran004 / gist:b94adcc72ebe5eab23190b065dbe9ebb
Created November 6, 2018 15:48
AION GQL API - NONCE and NRG PRICE
NONCE_NRGPRICE_QUERY: string = `
query nonce($address: String!) {
chainApi {
nonce(address: $address)
}
txnApi {
nrgPrice
}
}`
@satran004
satran004 / gist:8e07a321a4cb3709146344fc0e2dd6ed
Created November 6, 2018 15:51
AION GraphQL - Get balance of an account
BALANCE_QUERY: string = `
query balance($address: String!) {
chainApi {
balance(address: $address)
}
}`
@satran004
satran004 / gist:6be067c0ef1e8fdffd1b08188ed5c1a0
Created November 6, 2018 15:54
AION GraphQL API - sendRawTransaction
SEND_RAWTXN_QUERY: string = `
mutation sendRawTransaction($encodedTx: String!) {
txnApi {
sendRawTransaction(encodedTx: $encodedTx) {
status
msgHash
txHash
txResult
txDeploy
error
@satran004
satran004 / gist:4829d8476c2724ae2ad7256f02c91804
Created November 6, 2018 16:28
AION GraphQL - Get Blocks
BLOCKS_QUERY: string = `
query blocks($first: Long) {
blockApi {
blocks(first: $first) {
number
hash
parentHash
nrgLimit
nrgConsumed
timestamp
@satran004
satran004 / Playground.hs
Created February 7, 2021 14:20
Plutus Playground Smart Contract
import Control.Monad (void)
import Data.Aeson (FromJSON, ToJSON)
import qualified Data.Text as T
import GHC.Generics (Generic)
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude
import Ledger
import qualified Ledger.Ada as Ada
import qualified Ledger.Constraints as Constraints
@satran004
satran004 / minttoken.java
Last active May 28, 2021 15:22
Mint Token
public void mintToken() throws ApiException, AddressExcepion, CborSerializationException {
BackendService backendService =
BackendFactory.getBlockfrostBackendService(Constants.BLOCKFROST_TESTNET_URL, Constant.BF_PROJECT_KEY);
FeeCalculationService feeCalculationService = backendService.getFeeCalculationService();
TransactionHelperService transactionHelperService = backendService.getTransactionHelperService();
BlockService blockService = backendService.getBlockService();
String senderMnemonic = "kit color frog trick speak employ suit sort bomb goddess jewel primary spoil fade person useless measure manage warfare reduce few scrub beyond era";
Account sender = new Account(Networks.testnet(), senderMnemonic);
public void transfer() throws ApiException, AddressExcepion, CborSerializationException {
BackendService backendService =
BackendFactory.getBlockfrostBackendService(Constants.BLOCKFROST_TESTNET_URL, Constant.BF_PROJECT_KEY);
FeeCalculationService feeCalculationService = backendService.getFeeCalculationService();
TransactionHelperService transactionHelperService = backendService.getTransactionHelperService();
BlockService blockService = backendService.getBlockService();
String senderMnemonic = "kit color frog trick speak employ suit sort bomb goddess jewel primary spoil fade person useless measure manage warfare reduce few scrub beyond era";
Account sender = new Account(Networks.testnet(), senderMnemonic);
public void transferWithMetadata() throws ApiException, AddressExcepion, CborSerializationException {
BackendService backendService =
BackendFactory.getBlockfrostBackendService(Constants.BLOCKFROST_TESTNET_URL, Constant.BF_PROJECT_KEY);
FeeCalculationService feeCalculationService = backendService.getFeeCalculationService();
TransactionHelperService transactionHelperService = backendService.getTransactionHelperService();
BlockService blockService = backendService.getBlockService();
String senderMnemonic = "kit color frog trick speak employ suit sort bomb goddess jewel primary spoil fade person useless measure manage warfare reduce few scrub beyond era";
Account sender = new Account(Networks.testnet(), senderMnemonic);
@satran004
satran004 / Txn.java
Created June 3, 2021 16:08
How to manually create and sign Transaction using cardano-client-lib
import com.bloxbean.cardano.client.account.Account;
import com.bloxbean.cardano.client.common.model.Networks;
import com.bloxbean.cardano.client.exception.CborDeserializationException;
import com.bloxbean.cardano.client.exception.CborSerializationException;
import com.bloxbean.cardano.client.transaction.spec.*;
import com.bloxbean.cardano.client.util.HexUtil;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
import com.bloxbean.cardano.client.account.Account;
import com.bloxbean.cardano.client.backend.api.BackendService;
import com.bloxbean.cardano.client.backend.api.BlockService;
import com.bloxbean.cardano.client.backend.api.helper.FeeCalculationService;
import com.bloxbean.cardano.client.backend.api.helper.TransactionHelperService;
import com.bloxbean.cardano.client.backend.api.helper.model.TransactionResult;
import com.bloxbean.cardano.client.backend.exception.ApiException;
import com.bloxbean.cardano.client.backend.gql.GqlBackendService;
import com.bloxbean.cardano.client.backend.model.Result;
import com.bloxbean.cardano.client.backend.model.TransactionContent;