Points Program: Earn rewards and contribute to the Fuel Network.Learn more →

Account

0xefb4b443bfc7F77deE514E0f6de6Cc3d97f89A2DC85a0192E8D143dbA45771980xefb4...7198

Solana Connector
This connector supports SVM compatible EOA accounts such as Phantom and Backpack.

Source Code
predicate;

use std::{
    b512::B512,
    constants::ZERO_B256,
    hash::{
        Hash,
        sha256,
    },
    ecr::{
        EcRecoverError,
        ed_verify,
    },
    tx::{
        tx_id,
        tx_witness_data,
    },
    bytes::Bytes,
};

const ASCII_MAP: [u8; 16] = [
    48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102
];

pub fn b256_to_ascii_bytes(val: b256) -> Bytes {
    let bytes = Bytes::from(val);
    let mut ascii_bytes = Bytes::with_capacity(64);
    let mut idx = 0;

    while idx < 32 {
        let b = bytes.get(idx).unwrap();
        ascii_bytes.push(ASCII_MAP[(b >> 4).as_u64()]);
        ascii_bytes.push(ASCII_MAP[(b & 15).as_u64()]);
	    idx = idx + 1;
    }

    ascii_bytes
}

configurable {
    SIGNER: b256 = ZERO_B256,
}

fn main(witness_index: u64) -> bool {
    let signature: B512 = tx_witness_data(witness_index).unwrap();
    let encoded = b256_to_ascii_bytes(tx_id());
    let result = ed_verify(SIGNER, signature, encoded);

    if result.is_ok() {
        return true;
    }

    // Otherwise, an invalid signature has been passed and we invalidate the Tx.
    false
}
Bytecode
0x1a403000504100301a445000ba49000032400481504100205d490000504100083240048220451300524510044a4400003ac5c446f2f99d83d0e2dc773bb77c619783f1389c4d0198bba9b48680b801770000000000000040436d9c539a9d74c5bf9fe3f424f15b815aa4c9709d470fe19c71ce8a2b01b05230313233343536373839616263646566cccccccccccc00020000000000000330