MyNearWallet
Web wallet for NEAR Protocol
Agora que já temos as classes e tipagens da aplicação, vamos começar criando nossos métodos de ler dados da blockchain utilizando *view*.
Vamos criar duas funções:
– Listar todas as eleições
– Listar eleição por ID
Para pegarmos uma eleição por ID, vamos utilizar o ID da mesma como chave em nosso UnorderedMap. Para os IDs nesse projeto iremos utilizar um incremento simples no valor:
import { NearBindgen, UnorderedMap, initialize, view} from 'near-sdk-js';
import { Election } from './model';
@NearBindgen({})
class VotingNear {
electionsCounterId: number
elections: UnorderedMap<Election> = new UnorderedMap<Election>("elections")
@initialize({})
init() {
this.electionsCounterId = 0
}
@view({})
get_all_elections() {
return this.elections.toArray()
}
@view({})
get_election({ electionId }: { electionId: number }): Election {
return this.elections.get(String(electionId))
}
}
Connect Your Wallet

What is a Wallet?
Safely store and transfer your crypto and NFTs.
No need to create new accounts or credentials. Connect your wallet and you are good to go!